
Marc Messéant (Customer) asked a question.
How to wipe a temporal document in test?
In my test suite, I create temporal document with my standard procedure so protected in noDelete level.
And the and of the test, in the teardown.xqy, I need to wipe the doc to start a new test with an empty database, I'm unable to do that.
I try to protect with an old date, but it's not possible and I don't find how to suppress the protection.
Is there a solution for that, I don't want to modify my code for the tests?
Thank for answer
Marc
Have You tried: temporal:document-wipe() ? This gets rid of all versions of the doc related to the main URI. Please look at the notes and you will see that You need a special privilege for this. You could always amp a teardown function and force the function to only work on the documents/database/collection you intend.
If you want to delete only a single version of a temporal document, that takes another approach.
That's what I do, I find a solution :
I protect the doc with a noDelete level and a duration of 0, and in the next transaction I wipe it.
But when I try to do this on a old version of document with an .{id}., I have an exception as "is not a temporal document URI". The version file is in the temporal collection. It's ok for the latest doc.
Hi Marc. Yes, "document wipe" is to delete what I call a "temporal stack." That is, you provide the URI of the document (the one that is used as well as a collection URI for all versions of the document,) and all versions are deleted. You cannot pass the URI of any specific version.
If you want finer control, or rather full power, you can use "admin override" as explained by David.
OK. With great power comes great responsibility. Read below understanding that what is there represents very sharp tools that should be used with care as irreversible damage can be done by using xdmp:document-delete() and temporarily loosing all the protection for which the temporal system was designed. If you use the approach below and cause the world to end, that would be unfortunate for us all.
General approach:
Don;t take the below verbatim - it may not be complete but shows the approach - I cobbled together notes from some internal tooling and docs. it may be outdated and incomplete, but gets you started. Also note that it is multiple xQuery statements separated by a semicolon. In reality, you would likely use 3x xdmp:invoke-function() calls.
Thank you for answer, It's at the return of too long holidays
I modify my code to resolve a problem that as the document was deleted before, I don't see it in the latest collection anymore as open too much my loop to select document. I restrict now to the document who have the same uri as a collection and all is ok!
The test of the message (not in temporal collection) gives me a bad direction to search.
Good news. You can use "admin override" as explained by David, if ever you need to clean up version documents that would be left over from your previous logic.