mongoose
- Version 7.5.2
- Published
- 2.64 MB
- 7 dependencies
- MIT license
Install
npm i mongoose
yarn add mongoose
pnpm add mongoose
Overview
Mongoose MongoDB ODM
Index
Namespaces
namespace mongoose
module 'mongoose' {}
class Aggregate
class Aggregate<ResultType> implements SessionOperation {}
property [Symbol.toStringTag]
[Symbol.toStringTag]: string;
property catch
catch: <TResult = never>( onrejected?: (reason: any) => TResult | PromiseLike<TResult>) => Promise<ResultType | TResult>;
Executes the query returning a
Promise
which will be resolved with either the doc(s) or rejected with the error. Like [.then()
](#query_Query-then), but only takes a rejection handler.
property finally
finally: (onfinally?: () => void) => Promise<ResultType>;
Executes the aggregation returning a
Promise
which will be resolved with.finally()
chained.
property options
options: AggregateOptions;
property then
then: <TResult1 = ResultType, TResult2 = never>( onfulfilled?: (value: ResultType) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>;
Provides promise for aggregate.
method [Symbol.asyncIterator]
[Symbol.asyncIterator]: () => AsyncIterableIterator<Unpacked<ResultType>>;
Returns an asyncIterator for use with [
for/await/of
loops](https://thecodebarbarian.com/getting-started-with-async-iterators-in-node-js) You do not need to call this function explicitly, the JavaScript runtime will call it for you.
method addCursorFlag
addCursorFlag: (flag: CursorFlag, value: boolean) => this;
Sets an option on this aggregation. This function will be deprecated in a future release.
Deprecated
method addFields
addFields: (arg: PipelineStage.AddFields['$addFields']) => this;
Appends a new $addFields operator to this aggregate pipeline. Requires MongoDB v3.4+ to work
method allowDiskUse
allowDiskUse: (value: boolean) => this;
Sets the allowDiskUse option for the aggregation query
method append
append: (...args: PipelineStage[]) => this;
Appends new operators to this aggregate pipeline
method collation
collation: (options: mongodb.CollationOptions) => this;
Set the collation.
method count
count: (fieldName: PipelineStage.Count['$count']) => this;
Appends a new $count operator to this aggregate pipeline.
method cursor
cursor: <DocType = any>(options?: Record<string, unknown>) => Cursor<DocType>;
Sets the cursor option for the aggregation query
method densify
densify: (arg: PipelineStage.Densify['$densify']) => this;
Appends a new $densify operator to this aggregate pipeline
method exec
exec: () => Promise<ResultType>;
Executes the aggregate pipeline on the currently bound Model.
method explain
explain: { (verbosity: mongodb.ExplainVerbosityLike): Promise<AnyObject>; (): Promise<AnyObject>;};
Execute the aggregation with explain
method facet
facet: (options: PipelineStage.Facet['$facet']) => this;
Combines multiple aggregation pipelines.
method fill
fill: (arg: PipelineStage.Fill['$fill']) => this;
Appends a new $fill operator to this aggregate pipeline
method graphLookup
graphLookup: (options: PipelineStage.GraphLookup['$graphLookup']) => this;
Appends new custom $graphLookup operator(s) to this aggregate pipeline, performing a recursive search on a collection.
method group
group: (arg: PipelineStage.Group['$group']) => this;
Appends new custom $group operator to this aggregate pipeline.
method hint
hint: (value: Record<string, unknown> | string) => this;
Sets the hint option for the aggregation query
method limit
limit: (num: PipelineStage.Limit['$limit']) => this;
Appends a new $limit operator to this aggregate pipeline.
Parameter num
maximum number of records to pass to the next stage
method lookup
lookup: (options: PipelineStage.Lookup['$lookup']) => this;
Appends new custom $lookup operator to this aggregate pipeline.
method match
match: (arg: PipelineStage.Match['$match']) => this;
Appends a new custom $match operator to this aggregate pipeline.
Parameter arg
$match operator contents
method model
model: { (model: Model<any>): this; (): Model<any, {}, {}, {}, any, any> };
Binds this aggregate to a model.
Parameter model
the model to which the aggregate is to be bound
Returns the current model bound to this aggregate object
method near
near: (arg: PipelineStage.GeoNear['$geoNear']) => this;
Appends a new $geoNear operator to this aggregate pipeline.
method option
option: (value: AggregateOptions) => this;
Lets you set arbitrary options, for middlewares or plugins.
method pipeline
pipeline: () => PipelineStage[];
Returns the current pipeline
method project
project: (arg: PipelineStage.Project['$project']) => this;
Appends a new $project operator to this aggregate pipeline.
method read
read: (pref: mongodb.ReadPreferenceLike) => this;
Sets the readPreference option for the aggregation query.
method readConcern
readConcern: (level: string) => this;
Sets the readConcern level for the aggregation query.
method redact
redact: ( expression: PipelineStage.Redact['$redact'], thenExpr: '$$DESCEND' | '$$PRUNE' | '$$KEEP' | AnyObject, elseExpr: '$$DESCEND' | '$$PRUNE' | '$$KEEP' | AnyObject) => this;
Appends a new $redact operator to this aggregate pipeline.
method replaceRoot
replaceRoot: ( newRoot: PipelineStage.ReplaceRoot['$replaceRoot']['newRoot'] | string) => this;
Appends a new $replaceRoot operator to this aggregate pipeline.
method sample
sample: (arg: PipelineStage.Sample['$sample']['size']) => this;
Appends new custom $sample operator to this aggregate pipeline.
method search
search: (options: PipelineStage.Search['$search']) => this;
Helper for [Atlas Text Search](https://www.mongodb.com/docs/atlas/atlas-search/tutorial/)'s
$search
stage.
method session
session: (session: mongodb.ClientSession | null) => this;
Sets the session for this aggregation. Useful for [transactions](/docs/transactions.html).
method skip
skip: (num: PipelineStage.Skip['$skip']) => this;
Appends a new $skip operator to this aggregate pipeline.
Parameter num
number of records to skip before next stage
method sort
sort: ( arg: string | Record<string, SortValues> | PipelineStage.Sort['$sort']) => this;
Appends a new $sort operator to this aggregate pipeline.
method sortByCount
sortByCount: (arg: string | PipelineStage.SortByCount['$sortByCount']) => this;
Appends a new $sortByCount operator to this aggregate pipeline. Accepts either a string field name or a pipeline object.
method unionWith
unionWith: (options: PipelineStage.UnionWith['$unionWith']) => this;
Appends new $unionWith operator to this aggregate pipeline.
method unwind
unwind: (...args: PipelineStage.Unwind['$unwind'][]) => this;
Appends new custom $unwind operator(s) to this aggregate pipeline.
interface AggregateOptions
interface AggregateOptions extends Omit<mongodb.AggregateOptions, 'session'>, SessionOption {}
index signature
[key: string]: any;
type AggregateExtract
type AggregateExtract<P> = P extends Aggregate<infer T> ? T : never;
Extract generic type from Aggregate class
Package Files (2)
Dependencies (7)
Dev Dependencies (42)
- @babel/core
- @babel/preset-env
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- acquit
- acquit-ignore
- acquit-require
- assert-browserify
- axios
- babel-loader
- benchmark
- bluebird
- broken-link-checker
- buffer
- cheerio
- crypto-browserify
- dotenv
- dox
- eslint
- eslint-plugin-markdown
- eslint-plugin-mocha-no-only
- express
- fs-extra
- highlight.js
- lodash.isequal
- lodash.isequalwith
- markdownlint-cli2
- marked
- mkdirp
- mocha
- moment
- mongodb-memory-server
- ncp
- nyc
- pug
- q
- sinon
- stream-browserify
- tsd
- typescript
- uuid
- webpack
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/mongoose
.
- Markdown[](https://www.jsdocs.io/package/mongoose)
- HTML<a href="https://www.jsdocs.io/package/mongoose"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3647 ms. - Missing or incorrect documentation? Open an issue for this package.