Catalog
admin is a database of rows about the server: collections, fields, indexes, users, views, and counters.
A fresh process already has database admin. listDatabases returns it before you create anything else. The rows describe the server. They are not a second copy of your documents. A find still reads each user document from its page.
Applying a command updates the catalog in memory. The checkpoint writes the rows, then truncates the log. A crash before the checkpoint replays the command. Startup reads the catalog and does not walk every document to rebuild the list of collections, the secondary indexes, or the text index.
The collections
| Collection | One row is |
|---|---|
admin.databases | A database name. |
admin.collections | A collection: its pages, its document count, and its id set. |
admin.fields | A field name and its type. The ODBC driver reads this when a client asks for columns. A collection the catalog does not know yet is sampled from its documents. |
admin.indexes | An index spec. |
admin.counters | An autoincrement field and last. See Autoincrement. |
admin.users | A user. The password is an Argon2id hash. See Security. |
admin.roles | A custom role and its actions. |
admin.views | A view: name, source, pipeline, and the kova options. |
mongosh "mongodb://127.0.0.1:27018/admin"
db.fields.find({ collection: "db.emp" })
db.indexes.find({ collection: "db.emp" })
db.counters.find()
Field rows appear as documents are written and the type is learned. A collection whose field list is empty is filled on startup by reading that collection once.
What you may write
The catalog is maintained by commands: create, createIndexes, createUser, and the rest. A direct insert into these collections is refused. The exception is an update of admin.counters, which is how you move last.
Users, roles, and views are read from admin on startup. Dropping a built-in role is refused. The last root user cannot be revoked or disabled.