CRUD

Insert, query, update and delete documents, with MongoDB's write and read concerns.

Read and write operations are MongoDB's, with the same query, projection and update operators. Any node receives the request and takes it to the range that holds each document.

Write and read

JavaScript
db.orders.insertMany([
  { customer: "Ana Ruiz", total: 149.5, status: "paid" },
  { customer: "Luis Gil", total: 32, status: "pending" },
]);

db.orders.find({ total: { $gt: 100 } }, { customer: 1, total: 1 });

db.orders.updateOne({ customer: "Luis Gil" }, { $set: { status: "paid" }, $inc: { attempts: 1 } });

db.orders.deleteMany({ status: "cancelled" });

bulkWrite, findAndModify and upserts work the same. The drivers' retryable writes and reads are on.

Write concern

ValueAnswers when
w: 1The write is in the log of the range leader.
w: "majority"A majority of the range replicas have it.

Read concern and reads on replicas

readConcern local and available always return data confirmed by a majority: you never see writes that could still be lost. With readPreference secondary or nearest, the router picks the closest replica whose closed timestamp covers the read; the leader publishes that timestamp 3 seconds behind its clock.

Schema validation

$jsonSchema and collection validators are checked on every write, with validationLevel and validationAction as in MongoDB.