Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Automattic/mongoose
/ functions
Functions
1,456 in github.com/Automattic/mongoose
⨍
Functions
1,456
◇
Types & classes
788
↓ 210 callers
Function
model
()
test/errors.validation.test.js:267
↓ 193 callers
Method
create
Creates a new document or documents
types/models.d.ts:323
↓ 137 callers
Method
findOne
Finds one document.
types/models.d.ts:486
↓ 104 callers
Method
get
* Overwrites native Map's `get()` function to support Mongoose getters. * * @api public * @method get * @memberOf Map
lib/types/map.js:55
↓ 97 callers
Method
find
Creates a `find` query: gets a list of documents that match `filter`.
types/models.d.ts:783
↓ 91 callers
Method
close
()
lib/cursor/changeStream.js:201
↓ 90 callers
Method
toObject
(options)
lib/types/map.js:226
↓ 88 callers
Method
set
* Sets a default option for all Map instances. * * @param {string} option The option you'd like to set the value for * @param {any} value val
lib/schema/map.js:43
↓ 70 callers
Method
toString
* toString helper * TODO remove? This defaults to `${this.name}: ${this.message}` * @api private
lib/error/validator.js:41
↓ 69 callers
Function
start
(ctx)
test/tracing.test.js:42
↓ 57 callers
Method
add
* Add a dotted path, like `settings.$*` or `profile.firstName`, to the trie. * * @param {string} path
lib/helpers/pathTrie.js:44
↓ 52 callers
Method
populate
Populates document references.
types/models.d.ts:667
↓ 51 callers
Method
test
(this: TestDoc)
test/types/loadclass.test.ts:166
↓ 50 callers
Method
deleteMany
* Deletes all of the documents that match `conditions` from the collection. * Behaves like `remove()`, but deletes all documents that match `cond
types/models.d.ts:358
↓ 50 callers
Method
findById
* Finds a single document by its _id field. `findById(id)` is almost* * equivalent to `findOne({ _id: id })`. If you want to query by a document'
types/models.d.ts:448
↓ 44 callers
Method
discriminator
Adds a discriminator type.
types/models.d.ts:410
↓ 41 callers
Method
validate
Casts and validates the given object against this model's schema, returning the casted-and-validated copy of `obj`, passing the given `context` to cus
types/models.d.ts:696
↓ 37 callers
Method
init
* This function is responsible for building [indexes](https://www.mongodb.com/docs/manual/indexes/), * unless [`autoIndex`](http://mongoosejs.com
types/models.d.ts:569
↓ 36 callers
Method
findOneAndUpdate
Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`.
types/models.d.ts:1201
↓ 35 callers
Method
cast
(val, doc, init, prev, options)
lib/schema/union.js:34
↓ 34 callers
Function
clone
* Object clone with Mongoose natives support. * * If options.minimize is true, creates a minimal data object. Empty objects and undefined values wil
lib/helpers/clone.js:33
↓ 34 callers
Method
updateOne
Creates a `updateOne` query: updates the first document that matches `filter` with `update`.
types/models.d.ts:1381
↓ 33 callers
Method
valueOf
()
test/helpers/clone.test.js:229
↓ 32 callers
Function
done
(err)
lib/model.js:1702
↓ 30 callers
Method
toJSON
()
lib/error/cast.js:33
↓ 28 callers
Method
insertMany
Inserts one or more new documents as a single `insertMany` call to the MongoDB server.
types/models.d.ts:572
↓ 26 callers
Method
aggregate
(pipeline?: PipelineStage[], options?: AggregateOptions)
types/models.d.ts:237
↓ 25 callers
Method
clone
()
lib/schema/union.js:120
↓ 25 callers
Function
get
()
lib/model.js:4405
↓ 24 callers
Method
where
Creates a Query, applies the passed conditions, and returns the Query.
types/models.d.ts:1393
↓ 22 callers
Method
deleteOne
* Deletes the first document that matches `conditions` from the collection. * Behaves like `remove()`, but deletes at most one document regardles
types/models.d.ts:386
↓ 22 callers
Function
isBsonType
* Determines if `obj` has the given BSON type. * @api private
lib/helpers/isBsonType.js:8
↓ 21 callers
Method
collection
()
test/driver.test.js:26
↓ 20 callers
Method
bulkWrite
* Sends multiple `insertOne`, `updateOne`, `updateMany`, `replaceOne`, * `deleteOne`, and/or `deleteMany` operations to the MongoDB server in one
types/models.d.ts:279
↓ 19 callers
Method
countDocuments
Creates a `countDocuments` query: counts the number of documents that match `filter`.
types/models.d.ts:299
↓ 18 callers
Method
applySetters
(val, doc, init, prev, options)
lib/schema/union.js:62
↓ 18 callers
Method
findOneAndDelete
Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion.
types/models.d.ts:989
↓ 17 callers
Method
on
(event, handler)
lib/cursor/changeStream.js:185
↓ 16 callers
Method
findByIdAndUpdate
Creates a `findOneAndUpdate` query, filtering by the given `_id`.
types/models.d.ts:903
↓ 16 callers
Function
fn
()
test/parallelLimit.test.js:17
↓ 16 callers
Method
insertOne
* Shortcut for saving one document to the database. * `MyModel.insertOne(obj, options)` is almost equivalent to `new MyModel(obj).save(options)`.
types/models.d.ts:655
↓ 15 callers
Method
findOneAndReplace
Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`.
types/models.d.ts:1079
↓ 15 callers
Method
hydrate
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB. * The document returned has no paths marked as modified initi
types/models.d.ts:554
↓ 15 callers
Method
inspect
()
lib/types/map.js:272
↓ 13 callers
Method
createCollection
* Create the collection for this model. By default, if no indexes are specified, * mongoose will not create the collection for the model until an
types/models.d.ts:336
↓ 13 callers
Method
distinct
Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`.
types/models.d.ts:714
↓ 13 callers
Function
next
(cb)
test/helpers/cursor.eachAsync.test.js:15
↓ 13 callers
Method
replaceOne
Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`.
types/models.d.ts:1347
↓ 13 callers
Method
updateMany
Creates a `updateMany` query: updates all documents that match `filter` with `update`.
types/models.d.ts:1369
↓ 12 callers
Method
next
(cb)
lib/cursor/changeStream.js:119
↓ 11 callers
Method
cast
(val)
test/document.test.js:8599
↓ 11 callers
Method
once
(event, handler)
lib/cursor/changeStream.js:193
↓ 10 callers
Function
_updateParentPopulated
* If this is a document array, each element may contain single * populated paths, so we need to modify the top-level document's * populated cache. S
lib/types/documentArray/methods/index.js:514
↓ 10 callers
Function
buildMiddlewareFilter
* Builds a filter for kareem's execPre/execPost based on middleware options. * * @param {object} options - Options object that may contain `middlewa
lib/helpers/buildMiddlewareFilter.js:17
↓ 10 callers
Method
delete
* Overwrites native Map's `delete()` function to support change tracking. * * @api public * @method delete * @memberOf Map
lib/types/map.js:205
↓ 10 callers
Method
syncIndexes
* Makes the indexes in MongoDB match the indexes defined in this model's * schema. This function will drop any indexes that are not defined in
types/indexes.d.ts:49
↓ 9 callers
Function
cb
()
test/index.test.js:607
↓ 8 callers
Function
_updateSubdocIndexes
(arr)
lib/types/documentArray/methods/index.js:490
↓ 8 callers
Method
bulkSave
* Sends multiple `save()` calls in a single `bulkWrite()`. This is faster than * sending multiple `save()` calls because with `bulkSave()` there
types/models.d.ts:293
↓ 8 callers
Method
findByIdAndDelete
Creates a `findByIdAndDelete` query, filtering by the given `_id`.
types/models.d.ts:845
↓ 7 callers
Method
$init
(key, value)
lib/types/map.js:33
↓ 7 callers
Method
estimatedDocumentCount
Creates a `estimatedDocumentCount` query: counts the number of documents in the collection.
types/models.d.ts:748
↓ 7 callers
Method
getEmbeddedSchemaType
* Returns the embedded schema type (i.e. the `.$*` path) * * @api public
lib/schema/map.js:114
↓ 6 callers
Method
addError
* add message * @param {string} path * @param {string|Error} error * @api private
lib/error/validation.js:53
↓ 6 callers
Method
doValidate
(value, scope, options)
lib/schema/union.js:94
↓ 6 callers
Method
exists
* Returns a document with its `_id` if at least one document exists in the database that matches * the given `filter`, and `null` otherwise.
types/models.d.ts:761
↓ 6 callers
Function
handleTimestampOption
(arg, prop)
lib/helpers/schema/handleTimestampOption.js:9
↓ 6 callers
Method
openUri
()
test/driver.test.js:30
↓ 6 callers
Method
startSession
* Starts a [MongoDB session](https://www.mongodb.com/docs/manual/release-notes/3.6/#client-sessions) * for benefits like causal consistency, [ret
types/session.d.ts:26
↓ 6 callers
Method
toJSONSchema
* Returns this schema type's representation in a JSON schema. * * @param {object} [options] * @param {boolean} [options.useBsonType=false] If
lib/schema/union.js:134
↓ 6 callers
Method
watch
Watches the underlying collection for changes using [MongoDB change streams](https://www.mongodb.com/docs/manual/changeStreams/).
types/models.d.ts:702
↓ 5 callers
Method
createIndexes
* Similar to `ensureIndexes()`, except for it uses the [`createIndex`](https://mongodb.github.io/node-mongodb-native/7.0/classes/Collection.html#creat
types/indexes.d.ts:20
↓ 5 callers
Function
isOperator
* Checks whether an object is likely a pipeline operator * * @param {object} obj object to check * @return {boolean} * @api private
lib/aggregate.js:1231
↓ 5 callers
Method
listIndexes
* Lists the indexes currently defined in MongoDB. This may or may not be * the same as the indexes defined in your schema depending on whether yo
types/indexes.d.ts:41
↓ 5 callers
Method
myMethod
()
test/types/models.test.ts:265
↓ 5 callers
Method
set
* Overwrites native Map's `set()` function to support setters, `populate()`, * and change tracking. Note that Mongoose maps _only_ support strings
lib/types/map.js:89
↓ 4 callers
Function
_checkManualPopulation
(arr, docs)
lib/types/array/methods/index.js:1037
↓ 4 callers
Function
applyTimestampsToChildren
* Apply timestamps to any subdocuments * * @param {Schema} schema subdocument schema * @param {object} res subdocument * @param {object} [options]
lib/helpers/document/applyTimestamps.js:38
↓ 4 callers
Method
byName
(this: QueryWithHelpers<any, ITest, QueryHelpers>, name: string)
test/types/queries.test.ts:26
↓ 4 callers
Method
clear
* Overwrites native Map's `clear()` function to support change tracking. * * @api public * @method clear * @memberOf Map
lib/types/map.js:189
↓ 4 callers
Function
createTracedChannel
(name)
lib/tracing.js:20
↓ 4 callers
Method
diffIndexes
* Does a dry-run of Model.syncIndexes(), meaning that * the result of this function would be the result of * Model.syncIndexes().
types/indexes.d.ts:27
↓ 4 callers
Function
scrollThreadToBottom
()
docs/js/ask-ai.js:281
↓ 3 callers
Method
$toObject
()
lib/types/map.js:239
↓ 3 callers
Method
_bindEvents
()
lib/cursor/changeStream.js:56
↓ 3 callers
Function
_castMinMaxDistance
(self, val)
lib/schema/operators/geospatial.js:100
↓ 3 callers
Function
_setIsNew
(doc, val, hasOnlyPrimitiveValues)
lib/model.js:3303
↓ 3 callers
Function
applyTimestampsToChildren
(now, update, schema)
lib/helpers/update/applyTimestampsToChildren.js:12
↓ 3 callers
Function
applyTimestampsToUpdate
(now, createdAt, updatedAt, currentUpdate, options, upsert, isReplace)
lib/helpers/update/applyTimestampsToUpdate.js:15
↓ 3 callers
Method
bar
()
test/types/models.test.ts:34
↓ 3 callers
Function
cast$geometry
(val, self)
lib/schema/operators/geospatial.js:40
↓ 3 callers
Method
castObject
(obj: AnyObject, options?: { ignoreCastErrors?: boolean })
types/models.d.ts:258
↓ 3 callers
Function
defineKey
* Defines the accessor named prop on the incoming prototype. * @param {object} options * @param {string} options.prop * @param {boolean} options.su
lib/helpers/document/compile.js:68
↓ 3 callers
Method
doValidateSync
(value, scope, options)
lib/schema/union.js:108
↓ 3 callers
Function
eachAsync
()
test/types/queries.test.ts:225
↓ 3 callers
Method
ensureIndexes
* Sends `createIndex` commands to mongo for each index declared in the schema. * The `createIndex` commands are sent in series.
types/indexes.d.ts:33
↓ 3 callers
Function
fetch
(done)
lib/helpers/cursor/eachAsync.js:81
↓ 3 callers
Method
fullName
()
test/types/populate.test.ts:563
↓ 3 callers
Function
getVirtual
(schema, name)
lib/helpers/populate/getVirtual.js:9
↓ 3 callers
Function
inspectable
* Debug print helper * @param {any} representation * @api private
lib/drivers/node-mongodb-native/collection.js:318
next →
1–100 of 1,456, ranked by callers