unset option support
Hi ,
I need to unset the specific key in model.
ex: {"name":"David","status":1,"grade":"2C"} expect result to delete the grade key in above document
result: {"name":"David","status":1},
I know UNSET Clause in n1ql, similar option is support Ottoman Model?
Thanks,
hi @rajasekar-mu
Ottoman's model doesn't have any implementation for UNSET, but Maybe you can use replaceById to achieve it:
syntax:
Model.replaceById(id, newDocument);
e.g.
User.replaceById("12345", {"name":"David","status":1});
result:
{"name":"David","status":1,"grade":"2C"} ==> {"name":"David","status":1}
Note: If you need to execute it to update your entire documents in a collection, you can execute a migration or similar using an N1QL query.
Thanks @gsi-alejandro ,
If we have 30+ keys & subdocuments, its difficult to update replaceById. So could you add this feature.
hi @rajasekar-mu
The team will discuss this feature request.
I will notify you about the progress.
Best Regards.