Questions in couchbase lite C

When I am using the C API, I try to get a MutableDocument I previously saved from the database, modify it and save it back to db. However, When I try to modify the MutableDocument, it “terminate called after throwing an instance of ‘fleece::FleeceException’ what(): incorrect use of persistent shared keys: not in transaction
Aborted (core dumped)”. I don’t know where I am wrong or it is a bug of the C API?

my C++ code is below:

#include “include/cbl++/CouchbaseLite.hh”
#include “include/cbl/CouchbaseLite.h”

int main() {
cbl::Database db(“information-state”, {"/tmp", kCBLDatabase_Create});
cbl::MutableDocument doc = db.getMutableDocument(“foo”); // document “foo” is previously saved
doc.set(“new”,10); // crash here
return 0;

Well the error message seems pretty clear about what it wants you to do (do your writes inside of a transaction). @jens Is it expected to have to use a transaction just for a “set” ?

A transaction shouldn’t be required, and there shouldn’t be any uncaught C++ exceptions causing crashes, so this is definitely a bug.

@Jiajie_Huang, you can work around this by wrapping begin/end transaction calls around the code that operates on the document.