mongodb-odm
Skill by doctrine
Guides PHP developers using doctrine/mongodb-odm to map classes to MongoDB collections, query data, and avoid common ORM-style mistakes. It covers DocumentManager, references and embeds, Atlas Search and Vector Search.
Install mongodb-odm
Built from the published package, never by AI.
git clone --depth 1 https://github.com/doctrine/mongodb-odm /tmp/mongodb-odm && mkdir -p ~/.claude/skills && cp -r /tmp/mongodb-odm/skills/mongodb-odm ~/.claude/skills/mongodb-odmRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/doctrine/mongodb-odm /tmp/mongodb-odm && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/mongodb-odm/skills/mongodb-odm ~/.gemini/antigravity-cli/skills/mongodb-odmAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
The mongodb-odm skill is an implementation guide for doctrine/mongodb-odm, the PHP object-document mapper that persists plain PHP classes to MongoDB. It covers mapping with attributes such as #[Document], #[Id], #[ReferenceOne] and #[EmbedOne], the DocumentManager and unit of work, the Query Builder and Aggregation Builder, indexes, Atlas Search, Vector Search, Queryable Encryption, GridFS and hybrid Doctrine ORM and ODM setups.
It is aimed at developers writing, debugging or reviewing PHP code that uses Doctrine with MongoDB. The skill warns against treating the ODM like a SQL ORM, such as expecting automatic reference cascading, joining collections like tables, or calling flush() after every change. It also suggests the official MongoDB MCP Server for checking live data and index state.
Written from the project's SKILL.md and checked against it.
What it can do
- Mapping guidanceExplains #[Document], #[Field], #[Id] and inheritance rules for document classes.
- Relationship modelingCovers ReferenceOne, ReferenceMany, EmbedOne and EmbedMany, and when to embed or reference.
- Persistence workflowExplains DocumentManager, the unit of work, and batching changes into one flush.
- Query and aggregationShows Query Builder and Aggregation Builder usage, including findAndModify and upserts.
- PaginationDescribes offset and cursor paginators for query and aggregation builders since ODM 2.18.
- Indexes and searchCovers standard indexes, Atlas Search indexes and simple keyword search.
- Vector searchDescribes $vectorSearch with embeddings, plus hybrid text and vector search.
- Queryable encryptionCovers encrypting sensitive fields with #[Encrypt] on Atlas or Enterprise.
- Hybrid ORM and ODMDescribes linking Doctrine ORM SQL data with MongoDB ODM data in one app.
- Storage and lifecycleCovers GridFS, sharding, transactions, lifecycle events and schema migration.
What you need
- A PHP project using doctrine/mongodb-odm
- A MongoDB database
- MongoDB Atlas for Vector Search and Atlas Search
- MongoDB Enterprise 7.0+ for Queryable Encryption
Try asking
- Map a PHP Order class with a customer reference and embedded lines
- Write a Doctrine MongoDB Query Builder query for open orders
- Build a $vectorSearch aggregation for guide embeddings using ODM
Good to know
- Vector Search and Queryable Encryption are not to be assumed to work outside MongoDB Atlas.
- Queryable Encryption requires MongoDB Enterprise 7.0 or later.
- $vectorSearch, $search and $geoNear must be the first pipeline stage, and $merge or $out the last.
- Some features need newer ODM versions, such as Automated Embeddings in 2.17 and later.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: skills/mongodb-odm/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to mongodb-odm
All alternatives →Creates, configures and manages datasets on the Hugging Face Hub, including SQL-based querying and transformation. Built for people who edit dataset content and metadata directly, alongside the HF MCP server.
Diagnoses and repairs gbrain's Postgres access when a command or MCP result shows a GBRAIN_DB_ACCESS marker, or when the operator reports the brain database is down. It runs the hardcoded gbrain db-repair ladder and verifies the result with a re-probe.
Manages clusters, instances, and backups for AlloyDB for PostgreSQL. Built for creating, configuring, and administering AlloyDB databases, not general PostgreSQL or Cloud SQL instances.
Writes, reviews and migrates Supabase logs queries against the ClickHouse logs table served by the logs.all.otel endpoint. Built for developers who write Logs Explorer SQL or convert older BigQuery logs queries.
Diagnoses and fixes slow Paperclip PostgreSQL queries using Cloud and Neon evidence, local benchmarks, regression tests, and a pull request with passing checks. Built for engineers working on Paperclip.
Guides AI assistants through Prisma 8 projects built on @prisma/orm-postgres, @prisma/orm-sqlite, or @prisma/orm-mongo. It covers data contracts, migrations, typed queries and runtime setup for developers on Prisma 8.
Compare with hugging-face-datasets, db-repair or alloydb-basics
mongodb-odm: common questions
Does Doctrine MongoDB ODM support Vector Search outside Atlas?
The skill says not to assume Vector Search works outside MongoDB Atlas, and to confirm Atlas before recommending it.
Do references cascade automatically in Doctrine MongoDB ODM?
No. The skill says references only cascade when cascade is set on the mapping, while embeds cascade automatically.
How often should I call flush in Doctrine MongoDB ODM?
The skill advises batching changes and calling flush once per logical unit of work, typically 0 to 2 times per HTTP request.
How do I install mongodb-odm?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is mongodb-odm free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is mongodb-odm safe to use?
It scores 81 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to mongodb-odm?
Similar skills: hugging-face-datasets, db-repair, alloydb-basics, clickhouse-logs-queries.
