I can use the Add Documents REST endpoint to add a new field to an existing document (by specifying an existing _id).
Is there any way to remove a field using the Add Document endpoint? Going by the overall documentation, that should be possible by setting the field to Undefined, but I don’t know how to encode that in Json. I tried setting it to null, but that left a null value at the field value, as opposed to deleting the field from the document (which makes sense).
As a workaround, I could use the PATCH endpoint, but I’d prefer to use the Add Document endpoint if possible (and anyway I’m curious if it’s possible at all).
Interesting dilemma. I recommend using the rockset’s undefined type in your Add Document call. In your data block, set the field value that you wish to delete to the following:
"field_name": { "__rockset_type": "undefined" }
The resulting field will be empty - not null. Let me know if this works for you!
Ie. the field is present and set to an empty object. I would have expected the field not to be present at all, i.e. the query should only return _id, _event_time, _meta and _seq_no.
Thank you for reporting back! I’ll investigate why an empty object is returned instead of an undefined field. In the meantime, another method is to use _op and apply a REPSERT operation. In your example, this would look like:
Purposefully leave out the field you wish to delete, but include the rest of the fields. For more information about the _op field, check out the documentation on Special Fields.