Update docs of mongodb BulkWriteResult type (#43855)

* Update docs of mongodb BulkWriteResult type

* Update index.d.ts
This commit is contained in:
Igor Strebezhev
2020-04-13 13:03:15 -07:00
committed by GitHub
parent 2dd734125b
commit 64989f4ed4
+59 -4
View File
@@ -30,6 +30,7 @@
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Linus Unnebäck <https://github.com/LinusU>
// Richard Bateman <https://github.com/taxilian>
// Igor Strebezhev <https://github.com/xamgore>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
@@ -1851,24 +1852,78 @@ export interface BulkWriteResultUpsertedIdObject {
_id: ObjectId;
}
/** http://mongodb.github.io/node-mongodb-native/3.1/api/BulkWriteResult.html */
/** http://mongodb.github.io/node-mongodb-native/3.5/api/BulkWriteResult.html */
export interface BulkWriteResult {
ok: number;
/**
* Evaluates to `true` if the bulk operation correctly executes
*/
ok: boolean;
/**
* The number of documents inserted, excluding upserted documents.
*
* @see {@link nUpserted} for the number of documents inserted through an upsert.
*/
nInserted: number;
nUpdated: number;
nUpserted: number;
/**
* The number of documents selected for update.
*
* If the update operation results in no change to the document,
* e.g. `$set` expression updates the value to the current value,
* {@link nMatched} can be greater than {@link nModified}.
*/
nMatched: number;
/**
* The number of existing documents updated.
*
* If the update/replacement operation results in no change to the document,
* such as setting the value of the field to its current value,
* {@link nModified} can be less than {@link nMatched}
*/
nModified: number;
/**
* The number of documents inserted by an
* [upsert]{@link https://docs.mongodb.com/manual/reference/method/db.collection.update/#upsert-parameter}.
*/
nUpserted: number;
/**
* The number of documents removed.
*/
nRemoved: number;
// Returns an array of all inserted ids
getInsertedIds(): object[];
// Retrieve lastOp if available
getLastOp(): object;
// Returns raw internal result
getRawResponse(): object;
/**
* Returns the upserted id at the given index
* @param index the number of the upserted id to return, returns `undefined` if no result for passed in index
*/
getUpsertedIdAt(index: number): BulkWriteResultUpsertedIdObject;
// Returns an array of all upserted ids
getUpsertedIds(): BulkWriteResultUpsertedIdObject[];
// Retrieve the write concern error if any
getWriteConcernError(): WriteConcernError;
/**
* Returns a specific write error object
* @param index of the write error to return, returns `null` if there is no result for passed in index
*/
getWriteErrorAt(index: number): WriteError;
// Returns the number of write errors off the bulk operation
getWriteErrorCount(): number;
// Retrieve all write errors
getWriteErrors(): object[];
// Returns `true` if the bulk operation contains a write error
hasWriteErrors(): boolean;
}