sp_upsert - common get operation
void *sp_upsert(void *object, void *document); typedef int (*upsert_callback)(char **result, char **key, int *key_size, int key_count, char *src, int src_size, char *upsert, int upsert_size, void *arg);
sp_upsert(database, document): do a single-statement transaction.
sp_upsert(transaction, document): do a key update as a part of multi-statement transaction.
Object must be prepared by setting key and value fields. It is important that while setting key and value fields, only pointers are copied. Real data copies only during first operation.
Value field should contain user-supplied data, which should be enough to implement custom update or insert logic.
To enable upsert command, a db.database_name.index.upsert and optionally db.database_name.index.upsert_arg must be set to callback function pointer.
See Sophia repository upsert example.
On success, sp_set() returns 0. On error, it returns -1.
Database object commit: (1) rollback or (2) lock.