How automattic/mongoose works
Mongoose is a MongoDB object-modeling library. The documented workflow is to define a schema, create a model, construct or query documents, and persist or retrieve them through a connection. Its runtime also covers casting, validation, population, aggregation, and change streams. The map includes these major capabilities; several are represented by their implementation paths because their source was not sampled. Edges are limited to README statements and relationships visible in the supplied source excerpts or index.
Main entry points: model.js Models · query.js Queries · index.js Mongoose API · schema.js Schema Definition
Components 18
Modeling
- Mongoose API
lib/index.js - Schema Definition
lib/schema.js - Schema Types
lib/schema/array.js - Models
lib/model.js - Documents
lib/document.js - Validation
lib/error/validation.js
Data Operations
- Queries
lib/query.js - Population
lib/helpers/populate/createPopulateQueryFilter.js - Aggregation
lib/aggregate.js - Query Cursors
lib/cursor/queryCursor.js - Change Streams
lib/cursor/changeStream.js
Persistence
- Connections
lib/connection.js - MongoDB Driver
lib/drivers/node-mongodb-native/connection.js
Runtime Support
- Value Casting
lib/cast.js - Array Tracking
lib/types/array/methods/index.js - Error Types
lib/error/index.js
Other components
- Application Developer
- MongoDB
Connections 19
- Application Developer → Mongoose API: uses
README.md - Mongoose API → Schema Definition: defines
README.md - Mongoose API → Models: creates
README.md - Schema Definition → Schema Types: configures
- Schema Definition → Models: shapes
README.md - Models → Documents: creates
README.md - Documents → Validation: validates
lib/document.js - Models → Queries: queries
README.md - Queries → Value Casting: casts with
lib/query.js - Queries → Query Cursors: creates
lib/query.js - Query Cursors → Population: prepares
- Query Cursors → Queries: uses helpers
lib/cursor/queryCursor.js - Models → Connections: uses
- Connections → MongoDB Driver: delegates to
lib/drivers/node-mongodb-native/connection.js - MongoDB Driver → MongoDB: accesses
- Documents → Array Tracking: tracks changes
lib/types/array/methods/index.js - Queries → Error Types: raises
lib/query.js - Aggregation → MongoDB: runs pipelines
- Change Streams → MongoDB: watches changes