Model
Typed collection API and transaction-scoped models
Models expose the collection-level API you use most often. Transaction-scoped models created through ctx.use(Model) keep the same surface, but inject a session automatically.
import { , } from "mongster";
const = .({
: .(),
: .().(false),
}).();
const = ("tasks", );
await .({ : "Write docs" });
await .({ : false }).(5);
await .({ : "Write docs" }, { : { : true } });
await .({ : true });
const = await .().({ : true }).("done").();Read surface
findfindOnefindByIdcountestimatedCountdistinct
Write surface
insertOne,insertManycreateOne,createManyupdateOne,updateMany,findOneAndUpdatereplaceOne,findOneAndReplace,upsertOnedeleteOne,deleteMany,findOneAndDeletebulkWrite
Extra helpers
populateaggregateaggregateRawsyncIndexesgetCollectiongetCollectionNamepreandpost
Transaction models
ctx.use(Model) returns a transaction model with the same CRUD and query helpers. The difference is that the session is already wired into every operation.