meteor-mongo-minimongo
Skill10 starsChanged 3 months agoMITView on GitHub
Use when authoring or debugging Mongo queries in Meteor 3. Triggers on Mongo.Collection, find/findOne, server async vs client Minimongo sync, oplog vs change streams, indexes, selectors, modifiers, projections. Use this skill when the user asks about Mongo on the server or asks about Minimongo on the client.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- wekan/wekanedited, first seen Oct 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- wekan/wekan★ 21k99% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- release-publishingSkill
- skill-gap-auditSkill
- skill-maintenanceSkill
- meteor-accountsSkill
- meteor-blazeSkill
- meteor-cli-installationSkill
- meteor-community-packagesSkill
- meteor-debuggingSkill
- meteor-deploymentSkill
- meteor-methodsSkill
- meteor-modern-build-stackSkill
- meteor-nativeSkill
- meteor-pubsubSkill
- meteor-reactSkill
- meteor-securitySkill
- meteor-testingSkill
- meteor-typescriptSkill
- migrate-to-meteor-3Skill
- migrate-to-rspackSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 167
Use collation for locale-aware or case-insensitive selectors and sorting on both Mongo and Minimongo.
- Distinctive: line 187
Use sync Mongo on the server.
- Very specific: line 188
Use sync Mongo (findOne, insert, update, remove) in shared code.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.
Server reads
const doc = await Posts.findOneAsync(id);
const list = await Posts.find({ ownerId }, {
fields: { title: 1 }, sort: { createdAt: -1 }, limit: 50,
}).fetchAsync();
const count = await Posts.find({ ownerId }).countAsync();Server writes
const _id = await Posts.insertAsync({ title, ownerId });
await Posts.updateAsync({ _id }, { $set: { title } });
await Posts.removeAsync({ _id });Client reads (Minimongo)
The async API is isomorphic. Prefer it in shared code so the same line works on the server.
const doc = await Posts.findOneAsync(id); // works in shared/client/server
const list = await Posts.find({ ownerId }).fetchAsync();On the client, the operation reads in-memory Minimongo but the async API still
returns a real Promise. Code after await resumes in a later microtask. The
sync API also works client-side, but only there:
const doc = Posts.findOne(id); // client-only
const list = Posts.find({ ownerId }).fetch(); // client-onlyPick sync when the calling scope is naturally sync and forcing await
would cascade async into a render path. Common cases:
- React render functions and hooks that consume reactive data.
- Blaze template helpers.
- Tracker autoruns.
Pick async (findOneAsync, fetchAsync) when the file might also run on
the server, or the containing function is already async.
Indexes
Indexes are server-side. Create them on app startup:
import { Meteor } from "meteor/meteor";
import { Posts } from "/imports/api/posts";
Meteor.startup(async () => {
await Posts.createIndexAsync({ ownerId: 1, createdAt: -1 });
await Posts.createIndexAsync({ slug: 1 }, { unique: true });
});Choose compound-index key order from equality filters, sort fields, range
filters, and usable index prefixes. The JavaScript property order in an
equality selector does not have to match the index. Verify the chosen plan in
the Mongo shell (meteor mongo) with
db.posts.find(...).explain("executionStats").
Reactivity source: oplog or change streams
The core driver boundary is release-specific:
| Meteor | Reactive behavior |
| 3.0 through 3.4 | Uses oplog when MONGO_OPLOG_URL is configured; otherwise polling. Core change streams and reactivity-order settings are unavailable. |
| 3.5+ | Chooses a driver per query in the default order below. |
Meteor 3.5+ defaults to:
changeStreams -> oplog -> pollingChange streams require MongoDB 6+ on a replica set or sharded cluster, an
unordered observer, no skip or limit, and a selector Minimongo can compile.
An ineligible query falls through to the next configured driver. Oplog is
available only when MONGO_OPLOG_URL is configured.
Meteor 3.6, verified on beta.3's mongo@2.5.2-beta360.3, also declines
$where/$near selectors for Change Streams (the RC resolves
mongo@2.5.2-rc360.0): live events cannot be re-matched
with MongoDB semantics by Minimongo. Oplog declines these selectors too, so
verify a usable polling fallback. Minimongo-incompatible projections also
require fallback. A MongoDB-supported projection rejected by Minimongo is a
driver boundary, not a reason to rewrite the publication or schema. Verify
fallback before proposing that broader change. Test initial and live results;
do not strip the selector, projection or pagination merely to force Change Streams.
Earlier 3.5/beta.1 packages can choose the wrong driver for $where/$near;
on a constrained release, use a supported polling configuration or an
authorized compatible upgrade and rerun the exact query.
On Meteor 3.5+, override the app-wide order with
METEOR_REACTIVITY_ORDER=oplog,polling or:
{
"packages": {
"mongo": {
"reactivity": ["oplog", "polling"]
}
}
}On Meteor 3.5+, the disable-oplog package removes only the oplog step. It
does not disable change streams. Use reactivity: ["polling"] to force
polling. On Meteor 3.0 through 3.4, do not add these settings; upgrade first.
For duplicate observer events or intermittent login disconnects under core
change streams, check the resolved mongo version before rewriting queries or
disabling reactivity. mongo@2.5.1 (Meteor 3.5.2) fixes replay of events already
covered by a causal primary snapshot. Earlier 3.5 packages lack that fix;
upgrade and rerun the failing sequence. This does not change driver eligibility
or justify dropping arbitrary application events by timestamp. Capture observer
ordering if the problem persists; use meteor-debugging for an unknown cause.
Collation (Meteor 3.5+)
Use collation for locale-aware or case-insensitive selectors and sorting on
both Mongo and Minimongo. Back the server query with an index created using
the same collation:
const collation = { locale: "en", strength: 2 };
const users = await Users.find(
{ email: "Alice@Example.COM" },
{ collation },
).fetchAsync();
await Users.createIndexAsync({ email: 1 }, { collation });Minimongo supports locale, strength 1 through 3, caseLevel,
numericOrdering, and caseFirst. Other Mongo collation options are
server-only and are ignored by Minimongo.
Anti-patterns
- Use sync Mongo on the server. Removed in Meteor 3.
- Use sync Mongo (
findOne,insert,update,remove) in shared code. Breaks the moment the file is imported on the server. - Unbounded
findon the server. Alwayslimit. - Forget
fieldsprojection when publishing. Always project. - Assume the async Minimongo API resumes inline. It returns a Promise even though the underlying read is local.
See also
references/server-vs-client.mdreferences/selectors-modifiers.mdreferences/eval-cases.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

