meteor-mongo-minimongo
Installation
SKILL.md
Mongo and Minimongo
Meteor ships two implementations of the Mongo API in one codebase. The server talks to MongoDB through an async driver. The client runs Minimongo, an in-memory synchronous Mongo emulator that holds the documents that subscriptions have shipped.
Decision flow
- Where does this code run?
- Server-only: use
await Collection.*Async(...). - Client-only: use
Collection.*(...)synchronously. - Isomorphic (
importin shared code): useawait Collection.*Async(...). On the client the work is local but still Promise-based; on the server it talks to Mongo.
- Server-only: use
- Does the query select more than a page of documents? Add
{ limit, skip }and an index that matches the selector. - Are you reading from a publication on the client? Use
find().fetch()(sync) withoutawait. The data is already local.