@andrewscwei/mongodb-odm
Advanced tools
Comparing version 0.57.0 to 0.58.0
@@ -45,4 +45,4 @@ /** | ||
* marked as required and has a random() function defined will have random | ||
* values generated. Specify `includeOptionals` to generate unrequired fields | ||
* as well. | ||
* values generated. Specify `includeOptionals` to generate unrequired | ||
* fields as well. | ||
* | ||
@@ -75,3 +75,4 @@ * @param fixedFields - A collection of fields that must be present in the | ||
* | ||
* @param query - Query used for the $match stage of the aggregation pipeline. | ||
* @param query - Query used for the $match stage of the aggregation | ||
* pipeline. | ||
* | ||
@@ -86,5 +87,6 @@ * @returns The matching ObjectID. | ||
* Same as the strict identify one operation but this method swallows all | ||
* errors and returns `null` if document canot be identified. | ||
* errors and returns `undefined` if document canot be identified. | ||
* | ||
* @param query - Query used for the $match stage of the aggregation pipeline. | ||
* @param query - Query used for the $match stage of the aggregation | ||
* pipeline. | ||
* | ||
@@ -95,3 +97,3 @@ * @returns The matching ObjectID. | ||
*/ | ||
identifyOne(query: db.Query<{}>): Promise<ObjectID | null>; | ||
identifyOne(query: db.Query<{}>): Promise<ObjectID | undefined>; | ||
/** | ||
@@ -106,6 +108,7 @@ * Returns an array of document IDs that match the query. | ||
/** | ||
* Finds one document from this collection using the aggregation framework. If | ||
* no query is specified, a random document will be fetched. | ||
* Finds one document from this collection using the aggregation framework. | ||
* If no query is specified, a random document will be fetched. | ||
* | ||
* @param query - Query used for the $match stage of the aggregation pipeline. | ||
* @param query - Query used for the $match stage of the aggregation | ||
* pipeline. | ||
* @param options - See `module:mongodb.Collection#aggregate`. | ||
@@ -121,5 +124,6 @@ * | ||
* Same as the strict find one operation but this method swallows all errors | ||
* and returns `null` when no document is found. | ||
* and returns `undefined` when no document is found. | ||
* | ||
* @param query - Query used for the $match stage of the aggregation pipeline. | ||
* @param query - Query used for the $match stage of the aggregation | ||
* pipeline. | ||
* @param options - See `module:mongodb.Collection#aggregate`. | ||
@@ -131,3 +135,3 @@ * | ||
*/ | ||
findOne<R_1 = T>(query?: string | ObjectID | FilterQuery<T> | undefined, options?: db.ModelFindOneOptions | undefined): Promise<db.Document<R_1> | null>; | ||
findOne<R_1 = T>(query?: string | ObjectID | FilterQuery<T> | undefined, options?: db.ModelFindOneOptions | undefined): Promise<db.Document<R_1> | undefined>; | ||
/** | ||
@@ -137,3 +141,4 @@ * Finds multiple documents of this collection using the aggregation | ||
* | ||
* @param query - Query used for the $match stage of the aggregation pipeline. | ||
* @param query - Query used for the $match stage of the aggregation | ||
* pipeline. | ||
* @param options - See `module:mongodb.Collection#aggregate`. | ||
@@ -163,3 +168,3 @@ * | ||
* Same as the strict insert one operation except this method swallows all | ||
* errors and returns null if the document cannot be inserted. | ||
* errors and returns `undefined` if the document cannot be inserted. | ||
* | ||
@@ -173,3 +178,3 @@ * @param doc - Document to be inserted. See `module:mongodb.Collection#insertOne`. | ||
*/ | ||
insertOne(doc?: Partial<db.Document<T>> | undefined, options?: db.ModelInsertOneOptions | undefined): Promise<db.Document<T> | null>; | ||
insertOne(doc?: Partial<db.Document<T>> | undefined, options?: db.ModelInsertOneOptions | undefined): Promise<db.Document<T> | undefined>; | ||
/** | ||
@@ -183,4 +188,4 @@ * Inserts multiple documents into this model's collection. | ||
* | ||
* @todo This method iterates through every document to apply the beforeInsert | ||
* hook. Consider a more cost-efficient approach? | ||
* @todo This method iterates through every document to apply the | ||
* `beforeInsert` hook. Consider a more cost-efficient approach? | ||
* | ||
@@ -195,13 +200,14 @@ * @see {@link http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertMany} | ||
/** | ||
* Updates one document matched by `query` with `update` object. Note that if | ||
* upserting, all *required* fields must be in the `query` param instead of | ||
* the `update` param. | ||
* Updates one document matched by `query` with `update` object. Note that | ||
* if upserting, all *required* fields must be in the `query` param instead | ||
* of the `update` param. | ||
* | ||
* @param query - Query for the document to update. | ||
* @param update - Either an object whose key/value pair represent the fields | ||
* belonging to this model to update to, or an update query. | ||
* @param update - Either an object whose key/value pair represent the | ||
* fields belonging to this model to update to, or an update | ||
* query. | ||
* @param options - See `ModelUpdateOneOptions`. | ||
* | ||
* @returns The updated doc if `returnDoc` is set to `true`, else there is no | ||
* fulfillment value. | ||
* @returns The updated doc if `returnDoc` is set to `true`, else there is | ||
* no fulfillment value. | ||
* | ||
@@ -222,8 +228,9 @@ * @see {@link https://docs.mongodb.com/manual/reference/operator/update-field/} | ||
* Same as the strict update one operation except this method swallows all | ||
* errors and returns `null` if no document was updated (and that `returnDoc` | ||
* is `true`) or `true`/`false` (if `returnDoc` is `false`). | ||
* errors and returns `undefined` if no document was updated (and that | ||
* `returnDoc` is `true`) or `true`/`false` (if `returnDoc` is `false`). | ||
* | ||
* @param query - Query for the document to update. | ||
* @param update - Either an object whose key/value pair represent the fields | ||
* belonging to this model to update to, or an update query. | ||
* @param update - Either an object whose key/value pair represent the | ||
* fields belonging to this model to update to, or an update | ||
* query. | ||
* @param options - See `ModelUpdateOneOptions`. | ||
@@ -237,3 +244,3 @@ * | ||
*/ | ||
updateOne(query: db.Query<T>, update: db.Update<T>, options?: db.ModelUpdateOneOptions): Promise<boolean | db.Document<T> | null>; | ||
updateOne(query: db.Query<T>, update: db.Update<T>, options?: db.ModelUpdateOneOptions): Promise<boolean | db.Document<T> | undefined>; | ||
/** | ||
@@ -243,8 +250,10 @@ * Updates multiple documents matched by `query` with `update` object. | ||
* @param query - Query for document to update. | ||
* @param update - Either an object whose key/value pair represent the fields | ||
* belonging to this model to update to, or an update query. | ||
* @param update - Either an object whose key/value pair represent the | ||
* fields belonging to this model to update to, or an update | ||
* query. | ||
* @param options - See `ModelUpdateManyOptions`. | ||
* | ||
* @returns The updated docs if `returnDocs` is set to `true`, else `true` or | ||
* `false` depending on whether or not the operation was successful. | ||
* @returns The updated docs if `returnDocs` is set to `true`, else `true` | ||
* or `false` depending on whether or not the operation was | ||
* successful. | ||
* | ||
@@ -273,4 +282,4 @@ * @see {@link https://docs.mongodb.com/manual/reference/operator/update-field/} | ||
* | ||
* @throws {Error} This method is called even though deletions are disabled in | ||
* the schema. | ||
* @throws {Error} This method is called even though deletions are disabled | ||
* in the schema. | ||
* @throws {Error} Unable to return the deleted document when `returnDoc` is | ||
@@ -293,3 +302,3 @@ * `true`. | ||
*/ | ||
deleteOne(query: db.Query<T>, options?: db.ModelDeleteOneOptions): Promise<boolean | db.Document<T> | null>; | ||
deleteOne(query: db.Query<T>, options?: db.ModelDeleteOneOptions): Promise<boolean | db.Document<T> | undefined>; | ||
/** | ||
@@ -301,4 +310,5 @@ * Deletes multiple documents matched by `query`. | ||
* | ||
* @returns The deleted docs if `returnDocs` is set to `true`, else `true` or | ||
* `false` depending on whether or not the operation was successful. | ||
* @returns The deleted docs if `returnDocs` is set to `true`, else `true` | ||
* or `false` depending on whether or not the operation was | ||
* successful. | ||
* | ||
@@ -321,4 +331,4 @@ * @see {@link http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#deleteMany} | ||
* | ||
* @returns The replaced document (by default) or the new document (depending | ||
* on the `returnOriginal` option). | ||
* @returns The replaced document (by default) or the new document | ||
* (depending on the `returnOriginal` option). | ||
* | ||
@@ -340,8 +350,9 @@ * @see {@link http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#findOneAndReplace} | ||
* | ||
* @returns The replaced document (by default) or the new document (depending | ||
* on the `returnOriginal` option) if available, `null` otherwise. | ||
* @returns The replaced document (by default) or the new document | ||
* (depending on the `returnOriginal` option) if available, | ||
* `undefined` otherwise. | ||
* | ||
* @see Model.findAndReplaceOneStrict | ||
*/ | ||
findAndReplaceOne(query: db.Query<T>, replacement?: Partial<db.Document<T>> | undefined, options?: db.ModelReplaceOneOptions): Promise<db.Document<T> | null>; | ||
findAndReplaceOne(query: db.Query<T>, replacement?: Partial<db.Document<T>> | undefined, options?: db.ModelReplaceOneOptions): Promise<db.Document<T> | undefined>; | ||
/** | ||
@@ -358,3 +369,4 @@ * Checks if a document exists. | ||
* | ||
* @param query - Query used for the $match stage of the aggregation pipeline. | ||
* @param query - Query used for the $match stage of the aggregation | ||
* pipeline. | ||
* | ||
@@ -366,4 +378,4 @@ * @returns The total number of documents found. The minimum is 0. | ||
* Returns a document whose values are formatted according to the format | ||
* function sdefined in the schema. If the field is marked as encrypted in the | ||
* schema, this process takes care of that too. | ||
* functions defined in the schema. If the field is marked as encrypted in | ||
* the schema, this process takes care of that too. | ||
* | ||
@@ -384,3 +396,4 @@ * @param doc - Document to format. | ||
* 2. Each field value conforms to the defined field spec. | ||
* 3. Unique indexes are enforced (only if `ignoreUniqueIndex` is disabled). | ||
* 3. Unique indexes are enforced (only if `ignoreUniqueIndex` is | ||
* disabled). | ||
* 4. No required fields are missing (only if `strict` is enabled). | ||
@@ -404,6 +417,6 @@ * | ||
/** | ||
* Handler called before an attempt to insert document into the database. This | ||
* is a good place to apply any custom pre-processing to the document before | ||
* it is inserted into the document. This method must return the document to | ||
* be inserted. | ||
* Handler called before an attempt to insert document into the database. | ||
* This is a good place to apply any custom pre-processing to the document | ||
* before it is inserted into the document. This method must return the | ||
* document to be inserted. | ||
* | ||
@@ -436,4 +449,5 @@ * @param doc - The document to be inserted. | ||
* | ||
* @param prevDoc - The document before it is updated. This is only available | ||
* if `returnDoc` was enabled, and only for updateOne(). | ||
* @param prevDoc - The document before it is updated. This is only | ||
* available if `returnDoc` was enabled, and only for | ||
* updateOne(). | ||
* @param newDocs - The updated document(s). This is only available if | ||
@@ -486,2 +500,4 @@ * `returnDoc` or `returnDocs` was enabled. | ||
* the schema. | ||
* | ||
* @todo Handle remaining update operators. | ||
*/ | ||
@@ -488,0 +504,0 @@ beforeUpdate(query: db.Query<T>, update: db.Update<T>, options?: db.ModelUpdateOneOptions | db.ModelUpdateManyOptions): Promise<[Partial<db.Document<T>>, UpdateQuery<Partial<db.Document<T>>>]>; |
@@ -22,3 +22,3 @@ import { CollectionAggregationOptions, CollectionInsertManyOptions, CollectionInsertOneOptions, CommonOptions, FilterQuery, FindOneAndReplaceOption, IndexOptions, ObjectID, ReplaceOneOptions, UpdateQuery } from 'mongodb'; | ||
export declare type Update<T = {}> = UpdateQuery<T> | Partial<{ | ||
[K in keyof Document<T>]: Document<T>[K] | null; | ||
[K in keyof Document<T>]: Document<T>[K] | undefined; | ||
}>; | ||
@@ -25,0 +25,0 @@ /** |
{ | ||
"name": "@andrewscwei/mongodb-odm", | ||
"version": "0.57.0", | ||
"version": "0.58.0", | ||
"description": "ODM for MongoDB", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
222052
3607