Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Automattic/mongoose
/ functions
Functions
1,018 in github.com/Automattic/mongoose
⨍
Functions
1,018
◇
Types & classes
646
↓ 129 callers
Method
create
Creates a new document or documents
types/models.d.ts:268
↓ 102 callers
Method
findOne
Finds one document.
types/models.d.ts:366
↓ 96 callers
Function
model
()
test/errors.validation.test.js:226
↓ 94 callers
Method
find
Creates a `find` query: gets a list of documents that match `filter`.
types/models.d.ts:555
↓ 91 callers
Method
get
* Overwrites native Map's `get()` function to support Mongoose getters. * * @api public * @method get * @memberOf Map
lib/types/map.js:54
↓ 83 callers
Method
set
(option, value)
lib/schema/map.js:20
↓ 81 callers
Method
close
()
lib/cursor/ChangeStream.js:141
↓ 66 callers
Method
toString
* toString helper * TODO remove? This defaults to `${this.name}: ${this.message}` * @api private
lib/error/validator.js:40
↓ 63 callers
Method
toObject
(options)
lib/types/map.js:212
↓ 52 callers
Method
populate
Populates document references.
types/models.d.ts:489
↓ 44 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:344
↓ 42 callers
Function
done
(err)
lib/model.js:1730
↓ 35 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:29
↓ 35 callers
Method
discriminator
Adds a discriminator type.
types/models.d.ts:14
↓ 34 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:404
↓ 33 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:288
↓ 30 callers
Function
callback
(err)
lib/schema/documentarray.js:255
↓ 29 callers
Method
cast
(val, doc, init)
lib/schema/map.js:24
↓ 29 callers
Method
findOneAndUpdate
Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`.
types/models.d.ts:714
↓ 29 callers
Method
on
(event, handler)
lib/cursor/ChangeStream.js:127
↓ 29 callers
Method
updateOne
Creates a `updateOne` query: updates the first document that matches `filter` with `update`.
types/models.d.ts:764
↓ 29 callers
Method
valueOf
()
test/helpers/clone.test.js:229
↓ 28 callers
Function
get
(v)
test/schema.test.js:2648
↓ 28 callers
Method
validate
Casts and validates the given object against this model's schema, passing the given `context` to custom validators.
types/models.d.ts:505
↓ 26 callers
Method
clone
()
lib/schema/map.js:62
↓ 25 callers
Function
fn
()
test/helpers/cursor.eachAsync.test.js:44
↓ 25 callers
Method
where
Creates a Query, applies the passed conditions, and returns the Query.
types/models.d.ts:771
↓ 24 callers
Function
next
(cb)
test/helpers/cursor.eachAsync.test.js:15
↓ 21 callers
Method
insertMany
Inserts one or more new documents as a single `insertMany` call to the MongoDB server.
types/models.d.ts:407
↓ 20 callers
Method
aggregate
(pipeline?: PipelineStage[], options?: AggregateOptions)
types/models.d.ts:205
↓ 19 callers
Method
collection
()
test/driver.test.js:26
↓ 19 callers
Function
isBsonType
* Get the bson type, if it exists * @api private
lib/helpers/isBsonType.js:8
↓ 18 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:313
↓ 17 callers
Method
insertOne
(doc, options)
test/driver.test.js:72
↓ 15 callers
Method
findByIdAndUpdate
Creates a `findOneAndUpdate` query, filtering by the given `_id`.
types/models.d.ts:618
↓ 14 callers
Method
inspect
()
lib/types/map.js:258
↓ 14 callers
Method
once
(event, handler)
lib/cursor/ChangeStream.js:132
↓ 13 callers
Method
countDocuments
Creates a `countDocuments` query: counts the number of documents that match `filter`.
types/models.d.ts:256
↓ 13 callers
Method
toJSON
()
lib/error/cast.js:33
↓ 12 callers
Function
cb
(err)
lib/schema/documentarray.js:233
↓ 12 callers
Function
next
(err)
lib/model.js:4354
↓ 11 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:655
↓ 10 callers
Function
Schema
* Schema constructor. * * #### Example: * * const child = new Schema({ name: String }); * const schema = new Schema({ name: String, age:
lib/schema.js:104
↓ 10 callers
Method
bulkWrite
* Sends multiple `insertOne`, `updateOne`, `updateMany`, `replaceOne`, * `deleteOne`, and/or `deleteMany` operations to the MongoDB server in one
types/models.d.ts:227
↓ 10 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:278
↓ 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:46
↓ 10 callers
Method
updateMany
Creates a `updateMany` query: updates all documents that match `filter` with `update`.
types/models.d.ts:757
↓ 9 callers
Method
count
Creates a `count` query: counts the number of documents that match `filter`.
types/models.d.ts:247
↓ 9 callers
Method
delete
* Overwrites native Map's `delete()` function to support change tracking. * * @api public * @method delete * @memberOf Map
lib/types/map.js:191
↓ 9 callers
Method
findOneAndReplace
Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`.
types/models.d.ts:681
↓ 9 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:394
↓ 9 callers
Method
replaceOne
Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`.
types/models.d.ts:747
↓ 8 callers
Method
cast
(val)
test/document.test.js:7933
↓ 8 callers
Method
distinct
Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`.
types/models.d.ts:523
↓ 7 callers
Method
$init
(key, value)
lib/types/map.js:32
↓ 7 callers
Method
next
(cb)
lib/cursor/ChangeStream.js:92
↓ 6 callers
Method
addError
* add message * @param {String} path * @param {String|Error} error * @api private
lib/error/validation.js:59
↓ 6 callers
Function
applyTimestampsToChildren
(now, update, schema)
lib/helpers/update/applyTimestampsToChildren.js:12
↓ 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
watch
Watches the underlying collection for changes using [MongoDB change streams](https://www.mongodb.com/docs/manual/changeStreams/).
types/models.d.ts:511
↓ 5 callers
Method
estimatedDocumentCount
Creates a `estimatedDocumentCount` query: counts the number of documents in the collection.
types/models.d.ts:532
↓ 5 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:544
↓ 5 callers
Method
findByIdAndDelete
Creates a `findByIdAndDelete` query, filtering by the given `_id`.
types/models.d.ts:582
↓ 5 callers
Method
findOneAndRemove
Creates a `findOneAndRemove` query: atomically finds the given document and deletes it.
types/models.d.ts:675
↓ 5 callers
Function
handleTimestampOption
(arg, prop)
lib/helpers/schema/handleTimestampOption.js:9
↓ 5 callers
Function
modifiedPaths
(update, path, result, recursion = null)
lib/helpers/common.js:72
↓ 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:81
↓ 4 callers
Function
_checkManualPopulation
(arr, docs)
lib/types/array/methods/index.js:997
↓ 4 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:368
↓ 4 callers
Method
byName
(this: QueryWithHelpers<any, ITest, QueryHelpers>, name: string)
test/types/queries.test.ts:27
↓ 4 callers
Function
cb
()
test/index.test.js:560
↓ 4 callers
Method
clear
* Overwrites native Map's `clear()` function to support change tracking. * * @api public * @method clear * @memberOf Map
lib/types/map.js:175
↓ 4 callers
Method
createIndexes
* Similar to `ensureIndexes()`, except for it uses the [`createIndex`](https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#creat
types/indexes.d.ts:17
↓ 4 callers
Method
getIndexes
Retrieves information about this collections indexes.
types/collection.d.ts:41
↓ 4 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:38
↓ 4 callers
Method
openUri
()
test/driver.test.js:30
↓ 4 callers
Method
toBSON
* Converts this map to a native JavaScript Map so the MongoDB driver can serialize it. * * @api public * @method toBSON * @memberOf Map
lib/types/map.js:208
↓ 3 callers
Method
$toObject
()
lib/types/map.js:225
↓ 3 callers
Method
_bindEvents
()
lib/cursor/ChangeStream.js:48
↓ 3 callers
Function
_castMinMaxDistance
(self, val)
lib/schema/operators/geospatial.js:100
↓ 3 callers
Function
applyTimestampsToUpdate
(now, createdAt, updatedAt, currentUpdate, options)
lib/helpers/update/applyTimestampsToUpdate.js:15
↓ 3 callers
Method
bar
()
test/types/models.test.ts:30
↓ 3 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:241
↓ 3 callers
Function
cast$geometry
(val, self)
lib/schema/operators/geospatial.js:40
↓ 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
Function
eachAsync
()
test/types/queries.test.ts:184
↓ 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:30
↓ 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:349
↓ 3 callers
Function
isLiteral
(val)
lib/helpers/query/cast$expr.js:282
↓ 3 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:1174
↓ 3 callers
Function
isPath
(val)
lib/helpers/query/cast$expr.js:278
↓ 3 callers
Function
merge
(schema, baseSchema)
lib/helpers/model/discriminator.js:83
↓ 3 callers
Method
start
()
test/connection_server.js:17
↓ 3 callers
Function
stringifySemverNumber
* Stringify a semver number array * @param {number[]} arr The array to stringify * @param {boolean} dotX If "true", return "5.X" instead of "5.5.5"
scripts/website.js:214
↓ 3 callers
Function
transform
(doc, ret)
test/document.test.js:817
↓ 3 callers
Method
translateAliases
Translate any aliases fields/conditions so the final query or document object is pure
types/models.d.ts:520
↓ 2 callers
Function
_assign
(model, vals, mod, assignmentOpts)
lib/model.js:4614
↓ 2 callers
Function
_castArrayFilters
(query)
lib/query.js:2248
↓ 2 callers
Function
_castExpression
(val, schema, strictQuery)
lib/helpers/query/cast$expr.js:78
next →
1–100 of 1,018, ranked by callers