Transactions
Barq changes happen inside write transactions.
Reads can happen outside a write. Creates, updates, and deletes must be inside a write.
JavaScript
Section titled “JavaScript”barq.write(() => { const task = barq.create(Task, { _id: new Barq.Types.ObjectId(), description: 'Write docs', });
task.done = true;});auto managed = database.write([&] { return database.add(Dog{.name = "Rex", .age = 1});});Keep Writes Small
Section titled “Keep Writes Small”Do only the needed data changes inside a write block.
Avoid slow network calls, long CPU work, or user prompts inside a write transaction.