// AUTO-GENERATED by scripts/generate-ops.mjs from src/operators.ts, // src/stages.ts, and vendor/mql-specifications. DO NOT EDIT — re-run // `npm run generate:ops` (or `npm run build`) after pulling new specs. // // User-facing import shape: // // import "@koresar/jsmql/ops"; // // Surfaces every jsmql stage and operator as an ambient global with a // precise signature, JSDoc description, and link to the MongoDB docs. // Also declares the `$$` / `$$$` / `$$$$` context references, with // completion for the collection- and cluster-scoped diagnostic stages. // The compiled module exports nothing at runtime (`export {};`), so the // import resolves to an empty module — bundlers tree-shake it away. For // fully zero-runtime use, add `"@koresar/jsmql/ops"` to tsconfig // compilerOptions.types instead. // // Why globals: named imports of these names break under every common // bundler (Vite, Webpack, esbuild). The transforms rewrite // `$match(args)` to `(0, _ops.$match)(args)`, which the jsmql parser // can't recognise. Ambient globals are the one shape that survives every // transform — and the collision risk is essentially nil because every // name starts with `$`. // // Drift protection: test/operator-spec-coverage.test.ts asserts this file // is byte-equal to the generator output on every `npm test`. declare global { // ── Stages ──────────────────────────────────────────────────────────── /** * Adds new fields to documents. Outputs documents that contain all existing fields from the input documents and newly added fields. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/ */ function $addFields(expression: any): any; /** * Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucket/ */ function $bucket(args: { /** An expression to group documents by. To specify a field path, prefix the field name with a dollar sign $ and enclose it in quotes. Unless $bucket includes a default specification, each input document must resolve the groupBy field path or expression to a value that falls within one of the ranges specified by the boundaries. */ groupBy: any; /** An array of values based on the groupBy expression that specify the boundaries for each bucket. Each adjacent pair of values acts as the inclusive lower boundary and the exclusive upper boundary for the bucket. You must specify at least two boundaries. The specified values must be in ascending order and all of the same type. The exception is if the values are of mixed numeric types, such as: */ boundaries: any; /** A literal that specifies the _id of an additional bucket that contains all documents whose groupBy expression result does not fall into a bucket specified by boundaries. If unspecified, each input document must resolve the groupBy expression to a value within one of the bucket ranges specified by boundaries or the operation throws an error. The default value must be less than the lowest boundaries value, or greater than or equal to the highest boundaries value. The default value can be of a different type than the entries in boundaries. */ default?: any; /** A document that specifies the fields to include in the output documents in addition to the _id field. To specify the field to include, you must use accumulator expressions. If you do not specify an output document, the operation returns a count field containing the number of documents in each bucket. If you specify an output document, only the fields specified in the document are returned; i.e. the count field is not returned unless it is explicitly included in the output document. */ output?: any; }): any; /** * Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression. Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bucketAuto/ */ function $bucketAuto(args: { /** An expression to group documents by. To specify a field path, prefix the field name with a dollar sign $ and enclose it in quotes. */ groupBy: any; /** A positive 32-bit integer that specifies the number of buckets into which input documents are grouped. */ buckets: any; /** A document that specifies the fields to include in the output documents in addition to the _id field. To specify the field to include, you must use accumulator expressions. The default count field is not included in the output document when output is specified. Explicitly specify the count expression as part of the output document to include it. */ output?: any; /** A string that specifies the preferred number series to use to ensure that the calculated boundary edges end on preferred round numbers or their powers of 10. Available only if the all groupBy values are numeric and none of them are NaN. */ granularity?: any; }): any; /** * Returns a Change Stream cursor for the collection or database. This stage can only occur once in an aggregation pipeline and it must occur as the first stage. * * @minVersion 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/ */ function $changeStream(args: { /** A flag indicating whether the stream should report all changes that occur on the deployment, aside from those on internal databases or collections. */ allChangesForCluster?: any; /** Specifies whether change notifications include a copy of the full document when modified by update operations. */ fullDocument?: any; /** Valid values are "off", "whenAvailable", or "required". If set to "off", the "fullDocumentBeforeChange" field of the output document is always omitted. If set to "whenAvailable", the "fullDocumentBeforeChange" field will be populated with the pre-image of the document modified by the current change event if such a pre-image is available, and will be omitted otherwise. If set to "required", then the "fullDocumentBeforeChange" field is always populated and an exception is thrown if the pre-image is not available. */ fullDocumentBeforeChange?: any; /** Specifies a resume token as the logical starting point for the change stream. Cannot be used with startAfter or startAtOperationTime fields. */ resumeAfter?: any; /** Specifies whether to include additional change events, such as such as DDL and index operations. */ showExpandedEvents?: any; /** Specifies a resume token as the logical starting point for the change stream. Cannot be used with resumeAfter or startAtOperationTime fields. */ startAfter?: any; /** Specifies a time as the logical starting point for the change stream. Cannot be used with resumeAfter or startAfter fields. */ startAtOperationTime?: any; }): any; /** * Splits large change stream events that exceed 16 MB into smaller fragments returned in a change stream cursor. * You can only use $changeStreamSplitLargeEvent in a $changeStream pipeline and it must be the final stage in the pipeline. * * @minVersion 6.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStreamSplitLargeEvent/ */ function $changeStreamSplitLargeEvent(): any; /** * Returns statistics regarding a collection or view. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/ */ function $collStats(args: { latencyStats?: any; storageStats?: any; count?: any; queryExecStats?: any }): any; /** * Returns a count of the number of documents at this stage of the aggregation pipeline. * Distinct from the $count aggregation accumulator. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/count/ */ function $count(field: string): any; function $count(): any; /** * Returns information on active and/or dormant operations for the MongoDB deployment. To run, use the db.aggregate() method. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/ */ function $currentOp(args: { allUsers?: any; idleConnections?: any; idleCursors?: any; idleSessions?: any; localOps?: any; }): any; /** * Creates new documents in a sequence of documents where certain values in a field are missing. * * @minVersion 5.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ */ function $densify(args: { /** The field to densify. The values of the specified field must either be all numeric values or all dates. Documents that do not contain the specified field continue through the pipeline unmodified. To specify a in an embedded document or in an array, use dot notation. */ field: string; /** The field(s) that will be used as the partition keys. */ partitionByFields?: any; /** Specification for range based densification. */ range: any; }): any; /** * Returns literal documents from input values. * * @minVersion 5.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/documents/ */ function $documents(documents: any): any; /** * Processes multiple aggregation pipelines within a single stage on the same set of input documents. Enables the creation of multi-faceted aggregations capable of characterizing data across multiple dimensions, or facets, in a single stage. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/ */ function $facet(facet: unknown[]): any; /** * Populates null and missing field values within documents. * * @minVersion 5.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ */ function $fill(args: { /** Specifies an expression to group the documents. In the $fill stage, a group of documents is known as a partition. If you omit partitionBy and partitionByFields, $fill uses one partition for the entire collection. partitionBy and partitionByFields are mutually exclusive. */ partitionBy?: any; /** Specifies an array of fields as the compound key to group the documents. In the $fill stage, each group of documents is known as a partition. If you omit partitionBy and partitionByFields, $fill uses one partition for the entire collection. partitionBy and partitionByFields are mutually exclusive. */ partitionByFields?: any; /** Specifies the field or fields to sort the documents within each partition. Uses the same syntax as the $sort stage. */ sortBy?: any; /** Specifies an object containing each field for which to fill missing values. You can specify multiple fields in the output object. The object name is the name of the field to fill. The object value specifies how the field is filled. */ output: any; }): any; /** * Returns an ordered stream of documents based on the proximity to a geospatial point. Incorporates the functionality of $match, $sort, and $limit for geospatial data. The output documents include an additional distance field and can include a location identifier field. * * @minVersion 2.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/geoNear/ */ function $geoNear(args: { /** The output field that contains the calculated distance. To specify a field within an embedded document, use dot notation. */ distanceField?: string; /** The factor to multiply all distances returned by the query. For example, use the distanceMultiplier to convert radians, as returned by a spherical query, to kilometers by multiplying by the radius of the Earth. */ distanceMultiplier?: any; /** This specifies the output field that identifies the location used to calculate the distance. This option is useful when a location field contains multiple locations. To specify a field within an embedded document, use dot notation. */ includeLocs?: string; /** Specify the geospatial indexed field to use when calculating the distance. */ key?: string; /** The maximum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall within the specified distance from the center point. Specify the distance in meters if the specified point is GeoJSON and in radians if the specified point is legacy coordinate pairs. */ maxDistance?: any; /** The minimum distance from the center point that the documents can be. MongoDB limits the results to those documents that fall outside the specified distance from the center point. Specify the distance in meters for GeoJSON data and in radians for legacy coordinate pairs. */ minDistance?: any; /** The point for which to find the closest documents. */ near: any; /** Limits the results to the documents that match the query. The query syntax is the usual MongoDB read operation query syntax. You cannot specify a $near predicate in the query field of the $geoNear stage. */ query?: any; /** Determines how MongoDB calculates the distance between two points: - When true, MongoDB uses $nearSphere semantics and calculates distances using spherical geometry. - When false, MongoDB uses $near semantics: spherical geometry for 2dsphere indexes and planar geometry for 2d indexes. Default: false. */ spherical?: any; }): any; /** * Performs a recursive search on a collection. To each output document, adds a new array field that contains the traversal results of the recursive search for that document. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/ */ function $graphLookup(args: { /** Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField. The from collection must be in the same database as any other collections used in the operation. Starting in MongoDB 5.1, the collection specified in the from parameter can be sharded. */ from: string; /** Expression that specifies the value of the connectFromField with which to start the recursive search. Optionally, startWith may be array of values, each of which is individually followed through the traversal process. */ startWith: any; /** Field name whose value $graphLookup uses to recursively match against the connectToField of other documents in the collection. If the value is an array, each element is individually followed through the traversal process. */ connectFromField: string; /** Field name in other documents against which to match the value of the field specified by the connectFromField parameter. */ connectToField: string; /** Name of the array field added to each output document. Contains the documents traversed in the $graphLookup stage to reach the document. */ as: string; /** Non-negative integral number specifying the maximum recursion depth. */ maxDepth?: any; /** Name of the field to add to each traversed document in the search path. The value of this field is the recursion depth for the document, represented as a NumberLong. Recursion depth value starts at zero, so the first lookup corresponds to zero depth. */ depthField?: string; /** A document specifying additional conditions for the recursive search. The syntax is identical to query filter syntax. */ restrictSearchWithMatch?: any; }): any; /** * Groups input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group. Consumes all input documents and outputs one document per each distinct group. The output documents only contain the identifier field and, if specified, accumulated fields. * * @minVersion 2.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/group/ */ function $group(args: { /** The _id expression specifies the group key. If you specify an _id value of null, or any other constant value, the $group stage returns a single document that aggregates values across all of the input documents. */ _id: any; /** Computed using the accumulator operators. */ field: any; }): any; /** * Returns statistics regarding the use of each index for the collection. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/ */ function $indexStats(): any; /** * Passes the first n documents unmodified to the pipeline where n is the specified limit. For each input document, outputs either one document (for the first n documents) or zero documents (after the first n documents). * * @minVersion 2.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/ */ function $limit(limit: any): any; /** * Lists all active sessions recently in use on the currently connected mongos or mongod instance. These sessions may have not yet propagated to the system.sessions collection. * * @minVersion 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/ */ function $listLocalSessions(args: { /** Returns all sessions for the specified users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster to list sessions for other users. */ users?: any; /** Returns all sessions for all users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster. */ allUsers?: any; }): any; /** * Lists sampled queries for all collections or a specific collection. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/ */ function $listSampledQueries(args: { namespace?: string }): any; /** * Returns information about existing Atlas Search indexes on a specified collection. * * @minVersion 7.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/ */ function $listSearchIndexes(args: { /** The id of the index to return information about. */ id?: string; /** The name of the index to return information about. */ name?: string; }): any; /** * Lists all sessions that have been active long enough to propagate to the system.sessions collection. * * @minVersion 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/ */ function $listSessions(args: { /** Returns all sessions for the specified users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster to list sessions for other users. */ users?: any; /** Returns all sessions for all users. If running with access control, the authenticated user must have privileges with listSessions action on the cluster. */ allUsers?: any; }): any; /** * Performs a left outer join to another collection in the same database to filter in documents from the "joined" collection for processing. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/ */ function $lookup(args: { /** Specifies the collection in the same database to perform the join with. from is optional, you can use a $documents stage in a $lookup stage instead. For an example, see Use a $documents Stage in a $lookup Stage. Starting in MongoDB 5.1, the collection specified in the from parameter can be sharded. */ from?: string; /** Specifies the field from the documents input to the $lookup stage. $lookup performs an equality match on the localField to the foreignField from the documents of the from collection. If an input document does not contain the localField, the $lookup treats the field as having a value of null for matching purposes. */ localField?: string; /** Specifies the field from the documents in the from collection. $lookup performs an equality match on the foreignField to the localField from the input documents. If a document in the from collection does not contain the foreignField, the $lookup treats the value as null for matching purposes. */ foreignField?: string; /** Specifies variables to use in the pipeline stages. Use the variable expressions to access the fields from the joined collection's documents that are input to the pipeline. */ let?: any; /** Specifies the pipeline to run on the joined collection. The pipeline determines the resulting documents from the joined collection. To return all documents, specify an empty pipeline []. The pipeline cannot include the $out stage or the $merge stage. Starting in v6.0, the pipeline can contain the Atlas Search $search stage as the first stage inside the pipeline. The pipeline cannot directly access the joined document fields. Instead, define variables for the joined document fields using the let option and then reference the variables in the pipeline stages. */ pipeline?: unknown[]; /** Specifies the name of the new array field to add to the input documents. The new array field contains the matching documents from the from collection. If the specified name already exists in the input document, the existing field is overwritten. */ as: string; }): any; /** * Filters the document stream to allow only matching documents to pass unmodified into the next pipeline stage. $match uses standard MongoDB queries. For each input document, outputs either one document (a match) or zero documents (no match). * * @minVersion 2.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/ */ function $match(query: any): any; /** * Writes the resulting documents of the aggregation pipeline to a collection. The stage can incorporate (insert new documents, merge documents, replace documents, keep existing documents, fail the operation, process documents with a custom update pipeline) the results into an output collection. To use the $merge stage, it must be the last stage in the pipeline. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/ */ function $merge(args: { /** The output collection. */ into: any; /** Field or fields that act as a unique identifier for a document. The identifier determines if a results document matches an existing document in the output collection. */ on?: any; /** Specifies variables for use in the whenMatched pipeline. */ let?: any; /** The behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s). */ whenMatched?: any; /** The behavior of $merge if a result document does not match an existing document in the out collection. */ whenNotMatched?: any; }): any; /** * Writes the resulting documents of the aggregation pipeline to a collection. To use the $out stage, it must be the last stage in the pipeline. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/out/ */ function $out(coll: any): any; /** * Returns plan cache information for a collection. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/ */ function $planCacheStats(): any; /** * Reshapes each document in the stream, such as by adding new fields or removing existing fields. For each input document, outputs one document. * * @minVersion 2.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/ */ function $project(specification: any): any; /** * Combines multiple pipelines using rank-based fusion to create hybrid search results. * * @minVersion 8.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rankFusion/ */ function $rankFusion(args: { /** An object that specifies the pipelines to combine with rank fusion. */ input: any; /** An object that specifies how to combine the ranked results. */ combination?: any; /** Set to true to include detailed scoring information. */ scoreDetails: any; }): any; /** * Reshapes each document in the stream by restricting the content for each document based on information stored in the documents themselves. Incorporates the functionality of $project and $match. Can be used to implement field level redaction. For each input document, outputs either one or zero documents. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/ */ function $redact(expression: any): any; /** * Replaces a document with the specified embedded document. The operation replaces all existing fields in the input document, including the _id field. Specify a document embedded in the input document to promote the embedded document to the top level. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot/ */ function $replaceRoot(args: { newRoot: any }): any; /** * Replaces a document with the specified embedded document. The operation replaces all existing fields in the input document, including the _id field. Specify a document embedded in the input document to promote the embedded document to the top level. * Alias for $replaceRoot. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceWith/ */ function $replaceWith(expression: any): any; /** * Randomly selects the specified number of documents from its input. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/ */ function $sample(args: { /** The number of documents to randomly select. */ size: any; }): any; /** * Combines multiple pipelines using relative score fusion to create hybrid search results. * * @minVersion 8.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/scoreFusion/ */ function $scoreFusion(args: { /** An object that specifies the pipelines to combine with score fusion. */ input: any; /** An object that specifies how to combine the scores. */ combination?: any; /** Set to true to include detailed scoring information. */ scoreDetails: any; }): any; /** * Performs a full-text search of the field or fields in an Atlas collection. * NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/ */ function $search(args: { /** Operator to search with. You can provide a specific operator or use the compound operator to run a compound query with multiple operators. */ operator: any; /** Name of the Atlas Search index to use. If omitted, defaults to "default". */ index?: string; /** Specifies the highlighting options for displaying search terms in their original context. */ highlight?: any; /** Parallelize search across segments on dedicated search nodes. If you don't have separate search nodes on your cluster, Atlas Search ignores this flag. If omitted, defaults to false. */ concurrent?: any; /** Document that specifies the count options for retrieving a count of the results. */ count?: any; /** Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point. */ searchAfter?: string; /** Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point. */ searchBefore?: string; /** Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false. */ scoreDetails?: any; /** Document that specifies the fields to sort the Atlas Search results by in ascending or descending order. */ sort?: any; /** Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search. */ returnStoredSource?: any; /** Document that specifies the tracking option to retrieve analytics information on the search terms. */ tracking?: any; }): any; /** * Returns different types of metadata result documents for the Atlas Search query against an Atlas collection. * NOTE: $searchMeta is only available for MongoDB Atlas clusters running MongoDB v4.4.9 or higher, and is not available for self-managed deployments. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/searchMeta/ */ function $searchMeta(args: { /** Operator to search with. You can provide a specific operator or use the compound operator to run a compound query with multiple operators. */ operator: any; /** Name of the Atlas Search index to use. If omitted, defaults to default. */ index?: string; /** Document that specifies the count options for retrieving a count of the results. */ count?: any; }): any; /** * Adds new fields to documents. Outputs documents that contain all existing fields from the input documents and newly added fields. * Alias for $addFields. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/set/ */ function $set(field: any): any; /** * Groups documents into windows and applies one or more operators to the documents in each window. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/ */ function $setWindowFields(args: { /** Specifies the field(s) to sort the documents by in the partition. Uses the same syntax as the $sort stage. Default is no sorting. */ sortBy: any; /** Specifies the field(s) to append to the documents in the output returned by the $setWindowFields stage. Each field is set to the result returned by the window operator. A field can contain dots to specify embedded document fields and array fields. The semantics for the embedded document dotted notation in the $setWindowFields stage are the same as the $addFields and $set stages. */ output: any; /** Specifies an expression to group the documents. In the $setWindowFields stage, the group of documents is known as a partition. Default is one partition for the entire collection. */ partitionBy?: any; }): any; /** * Provides data and size distribution information on sharded collections. * * @minVersion 6.0.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/ */ function $shardedDataDistribution(): any; /** * Skips the first n documents where n is the specified skip number and passes the remaining documents unmodified to the pipeline. For each input document, outputs either zero documents (for the first n documents) or one document (if after the first n documents). * * @minVersion 2.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/skip/ */ function $skip(skip: any): any; /** * Reorders the document stream by a specified sort key. Only the order changes; the documents remain unmodified. For each input document, outputs one document. * * @minVersion 2.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/ */ function $sort(sort: any): any; /** * Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/ */ function $sortByCount(expression: any): any; /** * Performs a union of two collections; i.e. combines pipeline results from two collections into a single result set. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith/ */ function $unionWith(args: { /** The collection or view whose pipeline results you wish to include in the result set. */ coll: string; /** An aggregation pipeline to apply to the specified coll. The pipeline cannot include the $out and $merge stages. Starting in v6.0, the pipeline can contain the Atlas Search $search stage as the first stage inside the pipeline. */ pipeline?: unknown[]; }): any; /** * Removes or excludes fields from documents. * Alias for $project stage that removes or excludes fields. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/unset/ */ function $unset(field: any): any; /** * Deconstructs an array field from the input documents to output a document for each element. Each output document replaces the array with an element value. For each input document, outputs n documents where n is the number of array elements and can be zero for an empty array. * * @minVersion 2.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/ */ function $unwind(args: { /** Field path to an array field. */ path: any; /** The name of a new field to hold the array index of the element. The name cannot start with a dollar sign $. */ includeArrayIndex?: string; /** If true, if the path is null, missing, or an empty array, $unwind outputs the document. If false, if path is null, missing, or an empty array, $unwind does not output a document. The default value is false. */ preserveNullAndEmptyArrays?: any; }): any; /** * The $vectorSearch stage performs an ANN or ENN search on a vector in the specified field. * * @minVersion 6.0 * @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/ */ function $vectorSearch(args: { /** Name of the Atlas Vector Search index to use. */ index: string; /** Number of documents to return in the results. This value can't exceed the value of numCandidates if you specify numCandidates. */ limit: any; /** Indexed vector type field to search. */ path: string; /** Array of numbers that represent the query vector. The number type must match the indexed field value type. */ queryVector: any; /** This is required if numCandidates is omitted. false to run ANN search. true to run ENN search. */ exact?: any; /** Any match query that compares an indexed field with a boolean, date, objectId, number (not decimals), string, or UUID to use as a pre-filter. */ filter?: any; /** This field is required if exact is false or omitted. Number of nearest neighbors to use during the search. Value must be less than or equal to (<=) 10000. You can't specify a number less than the number of documents to return (limit). */ numCandidates?: any; }): any; // ── Expression operators (incl. accumulators and window functions) ──── /** * Returns the absolute value of a number. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/abs/ */ function $abs(value: any): any; /** * Defines a custom accumulator function. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/accumulator/ */ function $accumulator(args: { /** Function used to initialize the state. The init function receives its arguments from the initArgs array expression. You can specify the function definition as either BSON type Code or String. */ init: any; /** Arguments passed to the init function. */ initArgs?: any; /** Function used to accumulate documents. The accumulate function receives its arguments from the current state and accumulateArgs array expression. The result of the accumulate function becomes the new state. You can specify the function definition as either BSON type Code or String. */ accumulate: any; /** Arguments passed to the accumulate function. You can use accumulateArgs to specify what field value(s) to pass to the accumulate function. */ accumulateArgs: any; /** Function used to merge two internal states. merge must be either a String or Code BSON type. merge returns the combined result of the two merged states. For information on when the merge function is called, see Merge Two States with $merge. */ merge: any; /** Function used to update the result of the accumulation. */ finalize?: any; /** The language used in the $accumulator code. */ lang: string; }): any; /** * Returns the inverse cosine (arc cosine) of a value in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/acos/ */ function $acos(expression: any): any; /** * Returns the inverse hyperbolic cosine (hyperbolic arc cosine) of a value in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/acosh/ */ function $acosh(expression: any): any; /** * Adds numbers to return the sum, or adds numbers and a date to return a new date. If adding numbers and a date, treats the numbers as milliseconds. Accepts any number of argument expressions, but at most, one expression can resolve to a date. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/add/ */ function $add(...expression: any[]): any; /** * Returns an array of unique expression values for each group. Order of the array elements is undefined. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @minVersion 2.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/addToSet/ */ function $addToSet(expression: any): any; /** * Returns true if no element of a set evaluates to false, otherwise, returns false. Accepts a single argument expression. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/allElementsTrue/ */ function $allElementsTrue(expression: any): any; /** * Returns true only when all its expressions evaluate to true. Accepts any number of argument expressions. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/and/ */ function $and(...expression: any[]): any; /** * Returns true if any elements of a set evaluate to true; otherwise, returns false. Accepts a single argument expression. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/anyElementTrue/ */ function $anyElementTrue(expression: any): any; /** * Returns the element at the specified array index. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayElemAt/ */ function $arrayElemAt(...array: any[]): any; /** * Converts an array of key value pairs to a document. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/arrayToObject/ */ function $arrayToObject(array: any): any; /** * Returns the inverse sin (arc sine) of a value in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/asin/ */ function $asin(expression: any): any; /** * Returns the inverse hyperbolic sine (hyperbolic arc sine) of a value in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/asinh/ */ function $asinh(expression: any): any; /** * Returns the inverse tangent (arc tangent) of a value in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan/ */ function $atan(expression: any): any; /** * Returns the inverse tangent (arc tangent) of y / x in radians, where y and x are the first and second values passed to the expression respectively. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atan2/ */ function $atan2(...y: any[]): any; /** * Returns the inverse hyperbolic tangent (hyperbolic arc tangent) of a value in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/atanh/ */ function $atanh(expression: any): any; /** * Returns an average of numerical values. Ignores non-numeric values. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/avg/ */ function $avg(expression: any): any; function $avg(...expressions: any[]): any; /** * Returns the size of a given string or binary data value's content in bytes. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/binarySize/ */ function $binarySize(expression: any): any; /** * Returns the result of a bitwise and operation on an array of int or long values. * * @minVersion 6.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitAnd/ */ function $bitAnd(...expression: any[]): any; /** * Returns the result of a bitwise not operation on a single argument or an array that contains a single int or long value. * * @minVersion 6.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitNot/ */ function $bitNot(expression: any): any; /** * Returns the result of a bitwise or operation on an array of int or long values. * * @minVersion 6.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitOr/ */ function $bitOr(...expression: any[]): any; /** * Returns the result of a bitwise xor (exclusive or) operation on an array of int and long values. * * @minVersion 6.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bitXor/ */ function $bitXor(...expression: any[]): any; /** * Returns the bottom element within a group according to the specified sort order. * * @minVersion 5.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottom/ */ function $bottom(args: { /** Represents the output for each element in the group and can be any expression. */ output: any; /** Specifies the order of results, with syntax similar to $sort. */ sortBy: any; }): any; /** * Returns an aggregation of the bottom n elements within a group, according to the specified sort order. If the group contains fewer than n elements, $bottomN returns all elements in the group. * Available in the $group and $setWindowFields stages. * * @minVersion 5.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bottomN/ */ function $bottomN(args: { /** Represents the output for each element in the group and can be any expression. */ output: any; /** Specifies the order of results, with syntax similar to $sort. */ sortBy: any; /** Limits the number of results per group and has to be a positive integral expression that is either a constant or depends on the _id value for $group. */ n: any; }): any; /** * Returns the size in bytes of a given document (i.e. BSON type Object) when encoded as BSON. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/bsonSize/ */ function $bsonSize(object: any): any; /** * Returns the smallest integer greater than or equal to the specified number. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ceil/ */ function $ceil(expression: any): any; /** * Returns 0 if the two values are equivalent, 1 if the first value is greater than the second, and -1 if the first value is less than the second. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/ */ function $cmp(...expression1: any[]): any; /** * Concatenates any number of strings. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/concat/ */ function $concat(...expression: any[]): any; /** * Concatenates arrays to return the concatenated array. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/concatArrays/ */ function $concatArrays(...array: any[]): any; /** * A ternary operator that evaluates one expression, and depending on the result, returns the value of one of the other two expressions. Accepts either three expressions in an ordered list or three named parameters. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cond/ */ function $cond(args: { if: any; then: any; else: any }): any; /** * Converts a value to a specified type. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/convert/ */ function $convert(args: { input: any; to: any; /** The value to return on encountering an error during conversion, including unsupported type conversions. The arguments can be any valid expression. If unspecified, the operation throws an error upon encountering an error and stops. */ onError?: any; /** The value to return if the input is null or missing. The arguments can be any valid expression. If unspecified, $convert returns null if the input is null or missing. */ onNull?: any; }): any; /** * Returns the cosine of a value that is measured in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cos/ */ function $cos(expression: any): any; /** * Returns the hyperbolic cosine of a value that is measured in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/cosh/ */ function $cosh(expression: any): any; /** * Returns the population covariance of two numeric expressions. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/covariancePop/ */ function $covariancePop(...expression1: any[]): any; /** * Returns the sample covariance of two numeric expressions. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/covarianceSamp/ */ function $covarianceSamp(...expression1: any[]): any; /** * Returns a random object ID * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/createObjectId/ */ function $createObjectId(): any; /** * Adds a number of time units to a date object. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateAdd/ */ function $dateAdd(args: { /** The beginning date, in UTC, for the addition operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ startDate: any; /** The unit used to measure the amount of time added to the startDate. */ unit: "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond"; amount: any; /** The timezone to carry out the operation. $timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. */ timezone?: any; }): any; /** * Returns the difference between two dates. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateDiff/ */ function $dateDiff(args: { /** The start of the time period. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ startDate: any; /** The end of the time period. The endDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ endDate: any; /** The time measurement unit between the startDate and endDate */ unit: "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond"; /** Used when the unit is equal to week. Defaults to Sunday. The startOfWeek parameter is an expression that resolves to a case insensitive string */ startOfWeek?: any; /** The timezone to carry out the operation. $timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. */ timezone?: any; }): any; /** * Constructs a BSON Date object given the date's constituent parts. * * @minVersion 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromParts/ */ function $dateFromParts(args: { /** Calendar year. Can be any expression that evaluates to a number. */ year?: any; /** Month. Defaults to 1. */ month?: any; /** Day of month. Defaults to 1. */ day?: any; /** Hour. Defaults to 0. */ hour?: any; /** Minute. Defaults to 0. */ minute?: any; /** Second. Defaults to 0. */ second?: any; /** Millisecond. Defaults to 0. */ millisecond?: any; /** The timezone to carry out the operation. $timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. */ timezone?: any; }): any; /** * Converts a date/time string to a date object. * * @minVersion 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateFromString/ */ function $dateFromString(args: { /** The date/time string to convert to a date object. */ dateString: any; /** The date format specification of the dateString. The format can be any expression that evaluates to a string literal, containing 0 or more format specifiers. If unspecified, $dateFromString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format but accepts a variety of formats and attempts to parse the dateString if possible. */ format?: any; /** The time zone to use to format the date. */ timezone?: any; /** If $dateFromString encounters an error while parsing the given dateString, it outputs the result value of the provided onError expression. This result value can be of any type. If you do not specify onError, $dateFromString throws an error if it cannot parse dateString. */ onError?: any; /** If the dateString provided to $dateFromString is null or missing, it outputs the result value of the provided onNull expression. This result value can be of any type. If you do not specify onNull and dateString is null or missing, then $dateFromString outputs null. */ onNull?: any; }): any; /** * Subtracts a number of time units from a date object. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateSubtract/ */ function $dateSubtract(args: { /** The beginning date, in UTC, for the addition operation. The startDate can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ startDate: any; /** The unit used to measure the amount of time added to the startDate. */ unit: "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond"; amount: any; /** The timezone to carry out the operation. $timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. */ timezone?: any; }): any; /** * Returns a document containing the constituent parts of a date. * * @minVersion 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToParts/ */ function $dateToParts(args: { /** The input date for which to return parts. date can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: any; /** The timezone to carry out the operation. $timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. */ timezone?: any; /** If set to true, modifies the output document to use ISO week date fields. Defaults to false. */ iso8601?: any; }): any; /** * Returns the date as a formatted string. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateToString/ */ function $dateToString(args: { /** The date to convert to string. Must be a valid expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: any; /** The date format specification of the dateString. The format can be any expression that evaluates to a string literal, containing 0 or more format specifiers. If unspecified, $dateFromString uses "%Y-%m-%dT%H:%M:%S.%LZ" as the default format but accepts a variety of formats and attempts to parse the dateString if possible. */ format?: any; /** The time zone to use to format the date. */ timezone?: any; /** The value to return if the date is null or missing. If unspecified, $dateToString returns null if the date is null or missing. */ onNull?: any; }): any; /** * Truncates a date. * * @minVersion 5.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dateTrunc/ */ function $dateTrunc(args: { /** The date to truncate, specified in UTC. The date can be any expression that resolves to a Date, a Timestamp, or an ObjectID. */ date: any; /** The unit of time, specified as an expression that must resolve to one of these strings: year, quarter, week, month, day, hour, minute, second. Together, binSize and unit specify the time period used in the $dateTrunc calculation. */ unit: "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond"; /** The numeric time value, specified as an expression that must resolve to a positive non-zero number. Defaults to 1. Together, binSize and unit specify the time period used in the $dateTrunc calculation. */ binSize?: any; /** The timezone to carry out the operation. $timezone must be a valid expression that resolves to a string formatted as either an Olson Timezone Identifier or a UTC Offset. If no timezone is provided, the result is displayed in UTC. */ timezone?: any; /** The start of the week. Used when unit is week. Defaults to Sunday. */ startOfWeek?: string; }): any; /** * Returns the day of the month for a date as a number between 1 and 31. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/ */ function $dayOfMonth(date: any): any; /** * Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday). * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/ */ function $dayOfWeek(date: any): any; /** * Returns the day of the year for a date as a number between 1 and 366 (leap year). * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/ */ function $dayOfYear(date: any): any; /** * Converts a value from degrees to radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/degreesToRadians/ */ function $degreesToRadians(expression: any): any; /** * Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. There are no gaps in the ranks. Ties receive the same rank. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/denseRank/ */ function $denseRank(): any; /** * Returns the average rate of change within the specified window. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/derivative/ */ function $derivative(args: { input: any; /** A string that specifies the time unit. Use one of these strings: "week", "day","hour", "minute", "second", "millisecond". If the sortBy field is not a date, you must omit a unit. If you specify a unit, you must specify a date in the sortBy field. */ unit?: "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond"; }): any; /** * Returns the result of dividing the first number by the second. Accepts two argument expressions. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/divide/ */ function $divide(...dividend: any[]): any; /** * Returns the position of a document (known as the document number) in the $setWindowFields stage partition. Ties result in different adjacent document numbers. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/documentNumber/ */ function $documentNumber(): any; /** * Returns true if a substring exists within the encrypted string. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/encStrContains/ */ function $encStrContains(args: { input: any; substring: any }): any; /** * Returns true if the encrypted string ends with the specified suffix. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/encStrEndsWith/ */ function $encStrEndsWith(args: { input: any; suffix: any }): any; /** * Returns true if the normalized encrypted string equals the specified string. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/encStrNormalizedEq/ */ function $encStrNormalizedEq(args: { input: any; string: any }): any; /** * Returns true if the encrypted string starts with the specified prefix. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/encStrStartsWith/ */ function $encStrStartsWith(args: { input: any; prefix: any }): any; /** * Returns true if the values are equivalent. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/ */ function $eq(...expression1: any[]): any; /** * Raises e to the specified exponent. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/exp/ */ function $exp(exponent: any): any; /** * Returns the exponential moving average for the numeric expression. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/expMovingAvg/ */ function $expMovingAvg(args: { input: any; /** An integer that specifies the number of historical documents that have a significant mathematical weight in the exponential moving average calculation, with the most recent documents contributing the most weight. You must specify either N or alpha. You cannot specify both. The N value is used in this formula to calculate the current result based on the expression value from the current document being read and the previous result of the calculation: */ N?: any; /** A double that specifies the exponential decay value to use in the exponential moving average calculation. A higher alpha value assigns a lower mathematical significance to previous results from the calculation. You must specify either N or alpha. You cannot specify both. */ alpha?: any; }): any; /** * Selects a subset of the array to return an array with only the elements that match the filter condition. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/filter/ */ function $filter(args: { input: any; /** A name for the variable that represents each individual element of the input array. If no name is specified, the variable name defaults to this. */ as?: string; /** An expression that resolves to a boolean value used to determine if an element should be included in the output array. The expression references each element of the input array individually with the variable name specified in as. */ cond: any; /** A number expression that restricts the number of matching array elements that $filter returns. You cannot specify a limit less than 1. The matching array elements are returned in the order they appear in the input array. If the specified limit is greater than the number of matching array elements, $filter returns all matching array elements. If the limit is null, $filter returns all matching array elements. */ limit?: any; }): any; /** * Returns the result of an expression for the first document in an array. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/first/ */ function $first(expression: any): any; /** * Returns a specified number of elements from the beginning of an array. * * @minVersion 5.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/firstN-array-element/ */ function $firstN(args: { /** An expression that resolves to the array from which to return n elements. */ input: any; /** An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. */ n: any; }): any; /** * Returns the largest integer less than or equal to the specified number. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/floor/ */ function $floor(expression: any): any; /** * Defines a custom function. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/function/ */ function $function(args: { /** The function definition. You can specify the function definition as either BSON\JavaScript or string. function(arg1, arg2, ...) { ... } */ body: any; /** Arguments passed to the function body. If the body function does not take an argument, you can specify an empty array [ ]. */ args: any; lang: string; }): any; /** * Returns the value of a specified field from a document. You can use $getField to retrieve the value of fields with names that contain periods (.) or start with dollar signs ($). * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/getField/ */ function $getField(args: { /** Field in the input object for which you want to return a value. field can be any valid expression that resolves to a string constant. If field begins with a dollar sign ($), place the field name inside of a $literal expression to return its value. */ field: any; /** Default: $$CURRENT A valid expression that contains the field for which you want to return a value. input must resolve to an object, missing, null, or undefined. If omitted, defaults to the document currently being processed in the pipeline ($$CURRENT). */ input?: any; }): any; /** * Returns true if the first value is greater than the second. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/ */ function $gt(...expression1: any[]): any; /** * Returns true if the first value is greater than or equal to the second. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/ */ function $gte(...expression1: any[]): any; /** * Generates and returns a binary hash value (BinData) from a UTF-8 string or binary data. Use $hash in an aggregation * pipeline to compute binary hashes for storage, verification, or comparison. To get a hexadecimal string instead of * binary data, use $hexHash. * * @minVersion 8.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/hash/ */ function $hash(args: { input: any; algorithm: string }): any; /** * Generates and returns an uppercase hexadecimal string representation of a hash value from a UTF-8 string or binary * data. Use $hexHash in an aggregation pipeline to compute hex-encoded hashes for storage, verification, or comparison. * To get binary data instead of a hexadecimal string, use $hash. * * @minVersion 8.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/hexHash/ */ function $hexHash(args: { input: any; algorithm: string }): any; /** * Returns the hour for a date as a number between 0 and 23. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/ */ function $hour(date: any): any; /** * Returns either the non-null result of the first expression or the result of the second expression if the first expression results in a null result. Null result encompasses instances of undefined values or missing fields. Accepts two expressions as arguments. The result of the second expression can be null. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ifNull/ */ function $ifNull(...expression: any[]): any; /** * Returns a boolean indicating whether a specified value is in an array. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/in/ */ function $in(...expression: any[]): any; /** * Searches an array for an occurrence of a specified value and returns the array index of the first occurrence. Array indexes start at zero. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfArray/ */ function $indexOfArray(...array: any[]): any; /** * Searches a string for an occurrence of a substring and returns the UTF-8 byte index of the first occurrence. If the substring is not found, returns -1. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfBytes/ */ function $indexOfBytes(...string: any[]): any; /** * Searches a string for an occurrence of a substring and returns the UTF-8 code point index of the first occurrence. If the substring is not found, returns -1 * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexOfCP/ */ function $indexOfCP(...string: any[]): any; /** * Returns the approximation of the area under a curve. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/integral/ */ function $integral(args: { input: any; /** A string that specifies the time unit. Use one of these strings: "week", "day","hour", "minute", "second", "millisecond". If the sortBy field is not a date, you must omit a unit. If you specify a unit, you must specify a date in the sortBy field. */ unit?: "year" | "quarter" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond"; }): any; /** * Determines if the operand is an array. Returns a boolean. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isArray/ */ function $isArray(expression: any): any; /** * Returns boolean true if the specified expression resolves to an integer, decimal, double, or long. * Returns boolean false if the expression resolves to any other BSON type, null, or a missing field. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isNumber/ */ function $isNumber(expression: any): any; /** * Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday). * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/ */ function $isoDayOfWeek(date: any): any; /** * Returns the week number in ISO 8601 format, ranging from 1 to 53. Week numbers start at 1 with the week (Monday through Sunday) that contains the year's first Thursday. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/ */ function $isoWeek(date: any): any; /** * Returns the year number in ISO 8601 format. The year starts with the Monday of week 1 (ISO 8601) and ends with the Sunday of the last week (ISO 8601). * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/ */ function $isoWeekYear(date: any): any; /** * Returns the result of an expression for the last document in an array. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/last/ */ function $last(expression: any): any; /** * Returns a specified number of elements from the end of an array. * * @minVersion 5.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lastN/#array-operator */ function $lastN(args: { /** An expression that resolves to the array from which to return n elements. */ input: any; /** An expression that resolves to a positive integer. The integer specifies the number of array elements that $firstN returns. */ n: any; }): any; /** * Defines variables for use within the scope of a subexpression and returns the result of the subexpression. Accepts named parameters. * Accepts any number of argument expressions. * * @minVersion 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/let/ */ function $let(args: { /** Assignment block for the variables accessible in the in expression. To assign a variable, specify a string for the variable name and assign a valid expression for the value. The variable assignments have no meaning outside the in expression, not even within the vars block itself. */ vars: any; /** The expression to evaluate. */ in: any; }): any; /** * Fills null and missing fields in a window using linear interpolation based on surrounding field values. * Available in the $setWindowFields stage. * * @minVersion 5.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearFill/ */ function $linearFill(expression: any): any; /** * Return a value without parsing. Use for values that the aggregation pipeline may interpret as an expression. For example, use a $literal expression to a string that starts with a dollar sign ($) to avoid parsing as a field path. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/literal/ */ function $literal(value: any): any; /** * Calculates the natural log of a number. * $ln is equivalent to $log: [ , Math.E ] expression, where Math.E is a JavaScript representation for Euler's number e. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ln/ */ function $ln(number: any): any; /** * Last observation carried forward. Sets values for null and missing fields in a window to the last non-null value for the field. * Available in the $setWindowFields stage. * * @minVersion 5.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/ */ function $locf(expression: any): any; /** * Calculates the log of a number in the specified base. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/log/ */ function $log(...number: any[]): any; /** * Calculates the log base 10 of a number. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/log10/ */ function $log10(number: any): any; /** * Returns true if the first value is less than the second. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/ */ function $lt(...expression1: any[]): any; /** * Returns true if the first value is less than or equal to the second. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/ */ function $lte(...expression1: any[]): any; /** * Removes whitespace or the specified characters from the beginning of a string. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ltrim/ */ function $ltrim(args: { /** The string to trim. The argument can be any valid expression that resolves to a string. */ input: any; /** The character(s) to trim from the beginning of the input. The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input. If unspecified, $ltrim removes whitespace characters, including the null character. */ chars?: any; }): any; /** * Applies a subexpression to each element of an array and returns the array of resulting values in order. Accepts named parameters. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/map/ */ function $map(args: { /** An expression that resolves to an array. */ input: any; /** A name for the variable that represents each individual element of the input array. If no name is specified, the variable name defaults to this. */ as?: any; /** An expression that is applied to each element of the input array. The expression references each element individually with the variable name specified in as. */ in: any; }): any; /** * Returns the maximum value that results from applying an expression to each document. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/max/ */ function $max(expression: any): any; function $max(...expressions: any[]): any; /** * Returns the n largest values in an array. Distinct from the $maxN accumulator. * * @minVersion 5.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/maxN-array-element/ */ function $maxN(args: { /** An expression that resolves to the array from which to return the maximal n elements. */ input: any; /** An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. */ n: any; }): any; /** * Returns an approximation of the median, the 50th percentile, as a scalar value. * This operator is available as an accumulator in these stages: * $group * $setWindowFields * It is also available as an aggregation expression. * * @minVersion 7.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/median/ */ function $median(args: { /** $median calculates the 50th percentile value of this data. input must be a field name or an expression that evaluates to a numeric type. If the expression cannot be converted to a numeric type, the $median calculation ignores it. */ input: any; /** The method that mongod uses to calculate the 50th percentile value. The method must be 'approximate'. */ method: any; }): any; /** * Combines multiple documents into a single document. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/mergeObjects/ */ function $mergeObjects(document: any): any; function $mergeObjects(...documents: any[]): any; /** * Access available per-document metadata related to the aggregation operation. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/ */ function $meta(keyword: string): any; /** * Returns the milliseconds of a date as a number between 0 and 999. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/ */ function $millisecond(date: any): any; /** * Returns the minimum value that results from applying an expression to each document. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/min/ */ function $min(expression: any): any; function $min(...expressions: any[]): any; /** * Returns the n smallest values in an array. Distinct from the $minN accumulator. * * @minVersion 5.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/minN-array-element/ */ function $minN(args: { /** An expression that resolves to the array from which to return the maximal n elements. */ input: any; /** An expression that resolves to a positive integer. The integer specifies the number of array elements that $maxN returns. */ n: any; }): any; /** * Returns the minute for a date as a number between 0 and 59. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/ */ function $minute(date: any): any; /** * Returns the remainder of the first number divided by the second. Accepts two argument expressions. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/mod/ */ function $mod(...dividend: any[]): any; /** * Returns the month for a date as a number between 1 (January) and 12 (December). * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/ */ function $month(date: any): any; /** * Multiplies numbers to return the product. Accepts any number of argument expressions. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/multiply/ */ function $multiply(...expression: any[]): any; /** * Returns true if the values are not equivalent. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/ */ function $ne(...expression1: any[]): any; /** * Returns the boolean value that is the opposite of its argument expression. Accepts a single argument expression. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/not/ */ function $not(expression: any): any; /** * Converts a document to an array of documents representing key-value pairs. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/objectToArray/ */ function $objectToArray(object: any): any; /** * Returns true when any of its expressions evaluates to true. Accepts any number of argument expressions. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/or/ */ function $or(...expression: any[]): any; /** * Returns an array of scalar values that correspond to specified percentile values. * This operator is available as an accumulator in these stages: * $group * $setWindowFields * It is also available as an aggregation expression. * * @minVersion 7.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/percentile/ */ function $percentile(args: { /** $percentile calculates the percentile values of this data. input must be a field name or an expression that evaluates to a numeric type. If the expression cannot be converted to a numeric type, the $percentile calculation ignores it. */ input: any; /** $percentile calculates a percentile value for each element in p. The elements represent percentages and must evaluate to numeric values in the range 0.0 to 1.0, inclusive. $percentile returns results in the same order as the elements in p. */ p: any; /** The method that mongod uses to calculate the percentile value. The method must be 'approximate'. */ method: any; }): any; /** * Raises a number to the specified exponent. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/pow/ */ function $pow(...number: any[]): any; /** * Returns an array of values that result from applying an expression to each document. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @minVersion 2.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/push/ */ function $push(expression: any): any; /** * Converts a value from radians to degrees. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/radiansToDegrees/ */ function $radiansToDegrees(expression: any): any; /** * Returns a random float between 0 and 1 * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rand/ */ function $rand(): any; /** * Outputs an array containing a sequence of integers according to user-defined inputs. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/range/ */ function $range(...start: any[]): any; /** * Returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rank/ */ function $rank(): any; /** * Applies an expression to each element in an array and combines them into a single value. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/reduce/ */ function $reduce(args: { /** Can be any valid expression that resolves to an array. If the argument resolves to a value of null or refers to a missing field, $reduce returns null. If the argument does not resolve to an array or null nor refers to a missing field, $reduce returns an error. */ input: any; /** The initial cumulative value set before in is applied to the first element of the input array. */ initialValue: any; /** A valid expression that $reduce applies to each element in the input array in left-to-right order. Wrap the input value with $reverseArray to yield the equivalent of applying the combining expression from right-to-left. During evaluation of the in expression, two variables will be available: - value is the variable that represents the cumulative value of the expression. - this is the variable that refers to the element being processed. */ in: any; }): any; /** * Applies a regular expression (regex) to a string and returns information on the first matched substring. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFind/ */ function $regexFind(args: { /** The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. */ input: any; /** The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern //. When using the regex //, you can also specify the regex options i and m (but not the s or x options) */ regex: any; options?: string; }): any; /** * Applies a regular expression (regex) to a string and returns information on the all matched substrings. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexFindAll/ */ function $regexFindAll(args: { /** The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. */ input: any; /** The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern //. When using the regex //, you can also specify the regex options i and m (but not the s or x options) */ regex: any; options?: string; }): any; /** * Applies a regular expression (regex) to a string and returns a boolean that indicates if a match is found or not. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/regexMatch/ */ function $regexMatch(args: { /** The string on which you wish to apply the regex pattern. Can be a string or any valid expression that resolves to a string. */ input: any; /** The regex pattern to apply. Can be any valid expression that resolves to either a string or regex pattern //. When using the regex //, you can also specify the regex options i and m (but not the s or x options) */ regex: any; options?: string; }): any; /** * Replaces all instances of a search string in an input string with a replacement string. * $replaceAll is both case-sensitive and diacritic-sensitive, and ignores any collation present on a collection. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceAll/ */ function $replaceAll(args: { /** The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null. */ input: any; /** The string to search for within the given input. Can be any valid expression that resolves to a string or a null. If find refers to a field that is missing, $replaceAll returns null. */ find: any; /** The string to use to replace all matched instances of find in input. Can be any valid expression that resolves to a string or a null. */ replacement: any; }): any; /** * Replaces the first instance of a matched string in a given input. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceOne/ */ function $replaceOne(args: { /** The string on which you wish to apply the find. Can be any valid expression that resolves to a string or a null. If input refers to a field that is missing, $replaceAll returns null. */ input: any; /** The string to search for within the given input. Can be any valid expression that resolves to a string or a null. If find refers to a field that is missing, $replaceAll returns null. */ find: any; /** The string to use to replace all matched instances of find in input. Can be any valid expression that resolves to a string or a null. */ replacement: any; }): any; /** * Returns an array with the elements in reverse order. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/reverseArray/ */ function $reverseArray(expression: any): any; /** * Rounds a number to a whole integer or to a specified decimal place. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/round/ */ function $round(number: any): any; function $round(...numbers: any[]): any; /** * Removes whitespace characters, including null, or the specified characters from the end of a string. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/rtrim/ */ function $rtrim(args: { /** The string to trim. The argument can be any valid expression that resolves to a string. */ input: any; /** The character(s) to trim from the beginning of the input. The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input. If unspecified, $ltrim removes whitespace characters, including the null character. */ chars?: any; }): any; /** * Randomly selects documents at a given rate. Used inside $match. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sampleRate/ */ function $sampleRate(expression: any): any; /** * Returns the seconds for a date as a number between 0 and 60 (leap seconds). * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/ */ function $second(date: any): any; /** * Returns a set with elements that appear in the first set but not in the second set; i.e. performs a relative complement of the second set relative to the first. Accepts exactly two argument expressions. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setDifference/ */ function $setDifference(...expression1: any[]): any; /** * Returns true if the input sets have the same distinct elements. Accepts two or more argument expressions. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setEquals/ */ function $setEquals(...expression: any[]): any; /** * Adds, updates, or removes a specified field in a document. You can use $setField to add, update, or remove fields with names that contain periods (.) or start with dollar signs ($). * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setField/ */ function $setField(args: { /** Field in the input object that you want to add, update, or remove. field can be any valid expression that resolves to a string constant. */ field: any; /** Document that contains the field that you want to add or update. input must resolve to an object, missing, null, or undefined. */ input: any; /** The value that you want to assign to field. value can be any valid expression. Set to $$REMOVE to remove field from the input document. */ value: any; }): any; /** * Returns a set with elements that appear in all of the input sets. Accepts any number of argument expressions. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIntersection/ */ function $setIntersection(...expression: any[]): any; /** * Returns true if all elements of the first set appear in the second set, including when the first set equals the second set; i.e. not a strict subset. Accepts exactly two argument expressions. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setIsSubset/ */ function $setIsSubset(...expression1: any[]): any; /** * Returns a set with elements that appear in any of the input sets. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/setUnion/ */ function $setUnion(...expression: any[]): any; /** * Returns the value from an expression applied to a document in a specified position relative to the current document in the $setWindowFields stage partition. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/shift/ */ function $shift(args: { /** Specifies an expression to evaluate and return in the output. */ output: any; /** Specifies an integer with a numeric document position relative to the current document in the output. For example: 1 specifies the document position after the current document. -1 specifies the document position before the current document. -2 specifies the document position that is two positions before the current document. */ by: any; /** Specifies an optional default expression to evaluate if the document position is outside of the implicit $setWindowFields stage window. The implicit window contains all the documents in the partition. The default expression must evaluate to a constant value. If you do not specify a default expression, $shift returns null for documents whose positions are outside of the implicit $setWindowFields stage window. */ default: any; }): any; /** * Returns the sigmoid of a value, defined as 1 / (1 + e^(-x)). The result is a value between 0 and 1. * * @minVersion 8.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sigmoid/ */ function $sigmoid(expression: any): any; /** * Returns the sine of a value that is measured in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sin/ */ function $sin(expression: any): any; /** * Returns the hyperbolic sine of a value that is measured in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sinh/ */ function $sinh(expression: any): any; /** * Returns the number of elements in the array. Accepts a single expression as argument. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/size/ */ function $size(expression: any): any; /** * Returns a subset of an array. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/slice/ */ function $slice(...expression: any[]): any; /** * Sorts the elements of an array. * * @minVersion 5.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortArray/ */ function $sortArray(args: { /** The array to be sorted. The result is null if the expression: is missing, evaluates to null, or evaluates to undefined If the expression evaluates to any other non-array value, the document returns an error. */ input: any; /** The document specifies a sort ordering. */ sortBy: any; }): any; /** * Splits a string into substrings based on a delimiter. Returns an array of substrings. If the delimiter is not found within the string, returns an array containing the original string. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/split/ */ function $split(...string: any[]): any; /** * Calculates the square root. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sqrt/ */ function $sqrt(number: any): any; /** * Calculates the population standard deviation of the input values. Use if the values encompass the entire population of data you want to represent and do not wish to generalize about a larger population. $stdDevPop ignores non-numeric values. * If the values represent only a sample of a population of data from which to generalize about the population, use $stdDevSamp instead. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevPop/ */ function $stdDevPop(expression: any): any; function $stdDevPop(...expressions: any[]): any; /** * Calculates the sample standard deviation of the input values. Use if the values encompass a sample of a population of data from which to generalize about the population. $stdDevSamp ignores non-numeric values. * If the values represent the entire population of data or you do not wish to generalize about a larger population, use $stdDevPop instead. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/stdDevSamp/ */ function $stdDevSamp(expression: any): any; function $stdDevSamp(...expressions: any[]): any; /** * Returns the number of UTF-8 encoded bytes in a string. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenBytes/ */ function $strLenBytes(expression: any): any; /** * Returns the number of UTF-8 code points in a string. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/strLenCP/ */ function $strLenCP(expression: any): any; /** * Performs case-insensitive string comparison and returns: 0 if two strings are equivalent, 1 if the first string is greater than the second, and -1 if the first string is less than the second. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/strcasecmp/ */ function $strcasecmp(...expression1: any[]): any; /** * Deprecated. Use $substrBytes or $substrCP. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/substr/ */ function $substr(...string: any[]): any; /** * Returns the substring of a string. Starts with the character at the specified UTF-8 byte index (zero-based) in the string and continues for the specified number of bytes. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrBytes/ */ function $substrBytes(...string: any[]): any; /** * Returns the substring of a string. Starts with the character at the specified UTF-8 code point (CP) index (zero-based) in the string and continues for the number of code points specified. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/substrCP/ */ function $substrCP(...string: any[]): any; /** * Returns the result of subtracting the second value from the first. If the two values are numbers, return the difference. If the two values are dates, return the difference in milliseconds. If the two values are a date and a number in milliseconds, return the resulting date. Accepts two argument expressions. If the two values are a date and a number, specify the date argument first as it is not meaningful to subtract a date from a number. * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/subtract/ */ function $subtract(...expression1: any[]): any; /** * Returns a sum of numerical values. Ignores non-numeric values. * Changed in MongoDB 5.0: Available in the $setWindowFields stage. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/sum/ */ function $sum(expression: any): any; function $sum(...expressions: any[]): any; /** * Evaluates a series of case expressions. When it finds an expression which evaluates to true, $switch executes a specified expression and breaks out of the control flow. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/ */ function $switch(args: { /** An array of control branch documents. Each branch is a document with the following fields: - case Can be any valid expression that resolves to a boolean. If the result is not a boolean, it is coerced to a boolean value. More information about how MongoDB evaluates expressions as either true or false can be found here. - then Can be any valid expression. The branches array must contain at least one branch document. */ branches: any; /** The path to take if no branch case expression evaluates to true. Although optional, if default is unspecified and no branch case evaluates to true, $switch returns an error. */ default?: any; }): any; /** * Returns the tangent of a value that is measured in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tan/ */ function $tan(expression: any): any; /** * Returns the hyperbolic tangent of a value that is measured in radians. * * @minVersion 4.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tanh/ */ function $tanh(expression: any): any; /** * Converts a value to an array. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toArray/ */ function $toArray(expression: any): any; /** * Converts value to a boolean. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toBool/ */ function $toBool(expression: any): any; /** * Converts value to a Date. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDate/ */ function $toDate(expression: any): any; /** * Converts value to a Decimal128. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDecimal/ */ function $toDecimal(expression: any): any; /** * Converts value to a double. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toDouble/ */ function $toDouble(expression: any): any; /** * Computes and returns the hash value of the input expression using the same hash function that MongoDB uses to create a hashed index. A hash function maps a key or string to a fixed-size numeric value. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toHashedIndexKey/ */ function $toHashedIndexKey(value: any): any; /** * Converts value to an integer. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toInt/ */ function $toInt(expression: any): any; /** * Converts value to a long. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLong/ */ function $toLong(expression: any): any; /** * Converts a string to lowercase. Accepts a single argument expression. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toLower/ */ function $toLower(expression: any): any; /** * Converts a string to an object. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObject/ */ function $toObject(expression: any): any; /** * Converts value to an ObjectId. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toObjectId/ */ function $toObjectId(expression: any): any; /** * Converts value to a string. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toString/ */ function $toString(expression: any): any; /** * Converts a string to a UUID. * * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUUID/ */ function $toUUID(expression: any): any; /** * Converts a string to uppercase. Accepts a single argument expression. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/toUpper/ */ function $toUpper(expression: any): any; /** * Returns the top element within a group according to the specified sort order. * Available in the $group and $setWindowFields stages. * * @minVersion 5.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/top/ */ function $top(args: { /** Represents the output for each element in the group and can be any expression. */ output: any; /** Specifies the order of results, with syntax similar to $sort. */ sortBy: any; }): any; /** * Returns an aggregation of the top n fields within a group, according to the specified sort order. * Available in the $group and $setWindowFields stages. * * @minVersion 5.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/topN/ */ function $topN(args: { /** Represents the output for each element in the group and can be any expression. */ output: any; /** Specifies the order of results, with syntax similar to $sort. */ sortBy: any; /** limits the number of results per group and has to be a positive integral expression that is either a constant or depends on the _id value for $group. */ n: any; }): any; /** * Removes whitespace or the specified characters from the beginning and end of a string. * * @minVersion 4.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/trim/ */ function $trim(args: { /** The string to trim. The argument can be any valid expression that resolves to a string. */ input: any; /** The character(s) to trim from the beginning of the input. The argument can be any valid expression that resolves to a string. The $ltrim operator breaks down the string into individual UTF code point to trim from input. If unspecified, $ltrim removes whitespace characters, including the null character. */ chars?: any; }): any; /** * Truncates a number to a whole integer or to a specified decimal place. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/trunc/ */ function $trunc(number: any): any; function $trunc(...numbers: any[]): any; /** * Returns the incrementing ordinal from a timestamp as a long. * * @minVersion 5.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsIncrement/ */ function $tsIncrement(expression: any): any; /** * Returns the seconds from a timestamp as a long. * * @minVersion 5.1 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/tsSecond/ */ function $tsSecond(expression: any): any; /** * Return the BSON data type of the field. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/type/ */ function $type(expression: any): any; /** * You can use $unsetField to remove fields with names that contain periods (.) or that start with dollar signs ($). * $unsetField is an alias for $setField using $$REMOVE to remove fields. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/unsetField/ */ function $unsetField(args: { /** Field in the input object that you want to add, update, or remove. field can be any valid expression that resolves to a string constant. */ field: any; /** Document that contains the field that you want to add or update. input must resolve to an object, missing, null, or undefined. */ input: any; }): any; /** * Returns the week number for a date as a number between 0 (the partial week that precedes the first Sunday of the year) and 53 (leap year). * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/ */ function $week(date: any): any; /** * Returns the year for a date as a number (e.g. 2014). * * @minVersion 2.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/ */ function $year(date: any): any; /** * Merge two arrays together. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/zip/ */ function $zip(args: { /** An array of expressions that resolve to arrays. The elements of these input arrays combine to form the arrays of the output array. If any of the inputs arrays resolves to a value of null or refers to a missing field, $zip returns null. If any of the inputs arrays does not resolve to an array or null nor refers to a missing field, $zip returns an error. */ inputs: any; /** A boolean which specifies whether the length of the longest array determines the number of arrays in the output array. The default value is false: the shortest array length determines the number of arrays in the output array. */ useLongestLength?: any; /** An array of default element values to use if the input arrays have different lengths. You must specify useLongestLength: true along with this field, or else $zip will return an error. If useLongestLength: true but defaults is empty or not specified, $zip uses null as the default value. If specifying a non-empty defaults, you must specify a default for each input array or else $zip will return an error. */ defaults?: any; }): any; // ── Context references ($$, $$$, $$$$) ──────────────────────────────── interface JsmqlCollectionRef { /** * Returns statistics regarding a collection or view. * * @minVersion 3.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/collStats/ */ collStats(options?: { latencyStats?: { histograms?: boolean }; storageStats?: { scale?: number }; count?: Record; queryExecStats?: Record; }): any; /** * Returns statistics regarding the use of each index for the collection. * * @minVersion 3.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/indexStats/ */ indexStats(): any; /** * Returns information about existing Atlas Search indexes on a specified collection. * * @minVersion 7.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSearchIndexes/ */ listSearchIndexes(options?: { id?: string; name?: string }): any; /** * Returns plan cache information for a collection. * * @minVersion 4.4 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/planCacheStats/ */ planCacheStats(): any; /** Take a window of the stream → `$skip` / `$limit`. */ slice(start: number, end?: number): JsmqlCollectionRef; /** Append documents / union collections → `$unionWith`. */ concat(...sources: any[]): JsmqlCollectionRef; /** Reshape each document → `$replaceWith`. */ map(transform: (doc: any) => any): JsmqlCollectionRef; /** Sort the stream → `$sort`. */ toSorted(compare: (a: any, b: any) => number): JsmqlCollectionRef; /** Reverse the preceding sort — flips the preceding `$sort`. */ toReversed(): JsmqlCollectionRef; /** Unwind an array field → `$unwind`. */ flatMap(transform: (doc: any) => any): JsmqlCollectionRef; /** Narrow the stream → `$match`. Sugar for `$$ = $$.filter(p)`. */ filter(predicate: (doc: any) => any): JsmqlCollectionRef; /** Append documents to the stream → `$unionWith`. */ push(...docs: any[]): JsmqlCollectionRef; [key: string]: any; } /** * jsmql current-collection context reference (`$$`, run on `db.coll.aggregate()`). Names a collection-scoped diagnostic source stage, or heads collection sugar (`$$.push(...)` → `$unionWith`, `$$.filter(...)`, stream methods, `$$ = ...`). * * @see https://github.com/koresar/jsmql/blob/master/docs/specs/context-references.md */ const $$: JsmqlCollectionRef; /** * jsmql current-database context reference (`$$$`, run on `db.aggregate()`). Heads cross-collection joins (`$$$.coll.find/filter(...)` → `$lookup`) and `$out` writes (`$$$.coll = ...`). Has no diagnostic source stages of its own — `$currentOp` & friends run on the admin database, reached via `$$$$`. * * @see https://github.com/koresar/jsmql/blob/master/docs/specs/context-references.md */ const $$$: { [key: string]: any }; /** * jsmql cluster/server context reference (`$$$$`, run on the admin database). Names a cluster-scoped diagnostic source stage, or heads cross-database joins (`$$$$.db.coll.find/filter(...)` → `$lookup`) and writes (`$$$$.db.coll = ...`). * * @see https://github.com/koresar/jsmql/blob/master/docs/specs/context-references.md */ const $$$$: { /** * Returns information on active and/or dormant operations for the MongoDB deployment. To run, use the db.aggregate() method. * * @minVersion 3.2 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/currentOp/ */ currentOp(options?: { allUsers?: boolean; idleConnections?: boolean; idleCursors?: boolean; idleSessions?: boolean; localOps?: boolean; targetAllNodes?: boolean; }): any; /** * Lists all active sessions recently in use on the currently connected mongos or mongod instance. These sessions may have not yet propagated to the system.sessions collection. * * @minVersion 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listLocalSessions/ */ listLocalSessions(options?: { users?: { user: string; db: string }[]; allUsers?: boolean }): any; /** * Lists sampled queries for all collections or a specific collection. * * @minVersion 5.0 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSampledQueries/ */ listSampledQueries(options?: { namespace?: string }): any; /** * Lists all sessions that have been active long enough to propagate to the system.sessions collection. * * @minVersion 3.6 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/listSessions/ */ listSessions(options?: { users?: { user: string; db: string }[]; allUsers?: boolean }): any; /** * Provides data and size distribution information on sharded collections. * * @minVersion 6.0.3 * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/shardedDataDistribution/ */ shardedDataDistribution(): any; [key: string]: any; }; } export {};