Is it possible to access the value that a document hat before an UPDATE statement was executed from a RETURNING clause?
I’m for instance removing an element from an array using the ARRAY_REMOVE function in an UPDATE statement and would like to return whether an element was removed. I would solve this by returning whether the value was previously contained in the array, but how can I access the old value in the RETURNING clause? If I reference any fields in the RETURNING, then I always get the already updated value, not the previous value before the update.
So I’m looking for something like that:
UPDATE bucket b
USE KEYS “some-key”
SET b.arr = ARRAY_REMOVE(b.arr, “foo”)
RETURNING ARRAY_CONTAINS(OLD(b).arr, “foo”)