.patch()
Applies JSON Patch changes to all records, or a specific record, in the database.
Method Syntaxdb.patch(thing, data)
NoteThis function patches the current document / record data with the specified JSON Patch data.
Arguments | Description | ||
---|---|---|---|
thing required | The table name or the specific | ||
data required | The JSON Patch data with which to patch the records. |
# Update all records in a table await db.patch('person', [ { "op": 'replace', "path": '/created_at', "value": datetime.datetime.utcnow() }, ]) # Update a record with a specific ID await db.patch(RecordID('person', 'tobie'), [ { "op": 'replace', "path": '/settings/active', "value": false }, { "op": 'add', "path": '/tags', "value": ['developer', 'engineer'] }, { "op": 'remove', "path": '/temp' }, ])
This function will run the following query in the database.
UPDATE $thing PATCH $data;