@@ -355,7 +355,7 @@ define.classMethod('find', {callback: false, promise:false, returns: [Cursor]});
355
355
* @param {boolean } [options.j=false] Specify a journal write concern.
356
356
* @param {boolean } [options.serializeFunctions=false] Serialize functions on any object.
357
357
* @param {boolean } [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
358
- * @param {Collection~writeOpCallback } [callback] The command result callback
358
+ * @param {Collection~insertWriteOpCallback } [callback] The command result callback
359
359
* @return {Promise } returns Promise if no callback passed
360
360
*/
361
361
Collection . prototype . insertOne = function ( doc , options , callback ) {
@@ -420,7 +420,7 @@ define.classMethod('insertOne', {callback: true, promise:true});
420
420
* @param {boolean } [options.j=false] Specify a journal write concern.
421
421
* @param {boolean } [options.serializeFunctions=false] Serialize functions on any object.
422
422
* @param {boolean } [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
423
- * @param {Collection~writeOpCallback } [callback] The command result callback
423
+ * @param {Collection~insertWriteOpCallback } [callback] The command result callback
424
424
* @return {Promise } returns Promise if no callback passed
425
425
*/
426
426
Collection . prototype . insertMany = function ( docs , options , callback ) {
@@ -652,6 +652,24 @@ define.classMethod('bulkWrite', {callback: true, promise:true});
652
652
* @param {Collection~WriteOpResult } result The result object if the command was executed successfully.
653
653
*/
654
654
655
+ /**
656
+ * @typedef {Object } Collection~insertWriteOpResult
657
+ * @property {Number } insertedCount The total amount of documents inserted.
658
+ * @property {object[] } ops All the documents inserted using insertOne/insertMany/replaceOne. Documents contain the _id field if forceServerObjectId == false for insertOne/insertMany
659
+ * @property {ObjectId[] } insertedIds All the generated _id's for the inserted documents.
660
+ * @property {object } connection The connection object used for the operation.
661
+ * @property {object } result The raw command result object returned from MongoDB (content might vary by server version).
662
+ * @property {Number } result.ok Is 1 if the command executed correctly.
663
+ * @property {Number } result.n The total count of documents inserted.
664
+ */
665
+
666
+ /**
667
+ * The callback format for inserts
668
+ * @callback Collection~insertWriteOpCallback
669
+ * @param {MongoError } error An error instance representing the error during the execution.
670
+ * @param {Collection~insertWriteOpResult } result The result object if the command was executed successfully.
671
+ */
672
+
655
673
/**
656
674
* Inserts a single document or a an array of documents into MongoDB.
657
675
* @method
@@ -662,7 +680,7 @@ define.classMethod('bulkWrite', {callback: true, promise:true});
662
680
* @param {boolean } [options.j=false] Specify a journal write concern.
663
681
* @param {boolean } [options.serializeFunctions=false] Serialize functions on any object.
664
682
* @param {boolean } [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
665
- * @param {Collection~writeOpCallback } [callback] The command result callback
683
+ * @param {Collection~insertWriteOpCallback } [callback] The command result callback
666
684
* @return {Promise } returns Promise if no callback passed
667
685
* @deprecated Use insertOne, insertMany or bulkWrite
668
686
*/
@@ -681,6 +699,27 @@ Collection.prototype.insert = function(docs, options, callback) {
681
699
682
700
define . classMethod ( 'insert' , { callback : true , promise :true } ) ;
683
701
702
+ /**
703
+ * @typedef {Object } Collection~updateWriteOpResult
704
+ * @property {Object } result The raw result returned from MongoDB, field will vary depending on server version.
705
+ * @property {Number } result.ok Is 1 if the command executed correctly.
706
+ * @property {Number } result.n The total count of documents scanned.
707
+ * @property {Number } result.nModified The total count of documents modified.
708
+ * @property {Object } connection The connection object used for the operation.
709
+ * @property {Number } matchedCount The number of documents that matched the filter.
710
+ * @property {Number } modifiedCount The number of documents that were modified.
711
+ * @property {Number } upsertedCount The number of documents upserted.
712
+ * @property {Object } upsertedId The upserted id.
713
+ * @property {ObjectId } upsertedId._id The upserted _id returned from the server.
714
+ */
715
+
716
+ /**
717
+ * The callback format for inserts
718
+ * @callback Collection~updateWriteOpCallback
719
+ * @param {MongoError } error An error instance representing the error during the execution.
720
+ * @param {Collection~updateWriteOpResult } result The result object if the command was executed successfully.
721
+ */
722
+
684
723
/**
685
724
* Update a single document on MongoDB
686
725
* @method
@@ -691,7 +730,7 @@ define.classMethod('insert', {callback: true, promise:true});
691
730
* @param {(number|string) } [options.w=null] The write concern.
692
731
* @param {number } [options.wtimeout=null] The write concern timeout.
693
732
* @param {boolean } [options.j=false] Specify a journal write concern.
694
- * @param {Collection~writeOpCallback } [callback] The command result callback
733
+ * @param {Collection~updateWriteOpCallback } [callback] The command result callback
695
734
* @return {Promise } returns Promise if no callback passed
696
735
*/
697
736
Collection . prototype . updateOne = function ( filter , update , options , callback ) {
@@ -739,7 +778,7 @@ define.classMethod('updateOne', {callback: true, promise:true});
739
778
* @param {(number|string) } [options.w=null] The write concern.
740
779
* @param {number } [options.wtimeout=null] The write concern timeout.
741
780
* @param {boolean } [options.j=false] Specify a journal write concern.
742
- * @param {Collection~writeOpCallback } [callback] The command result callback
781
+ * @param {Collection~updateWriteOpCallback } [callback] The command result callback
743
782
* @return {Promise } returns Promise if no callback passed
744
783
*/
745
784
Collection . prototype . replaceOne = function ( filter , update , options , callback ) {
@@ -788,7 +827,7 @@ define.classMethod('replaceOne', {callback: true, promise:true});
788
827
* @param {(number|string) } [options.w=null] The write concern.
789
828
* @param {number } [options.wtimeout=null] The write concern timeout.
790
829
* @param {boolean } [options.j=false] Specify a journal write concern.
791
- * @param {Collection~writeOpCallback } [callback] The command result callback
830
+ * @param {Collection~updateWriteOpCallback } [callback] The command result callback
792
831
* @return {Promise } returns Promise if no callback passed
793
832
*/
794
833
Collection . prototype . updateMany = function ( filter , update , options , callback ) {
@@ -892,6 +931,22 @@ Collection.prototype.update = function(selector, document, options, callback) {
892
931
893
932
define . classMethod ( 'update' , { callback : true , promise :true } ) ;
894
933
934
+ /**
935
+ * @typedef {Object } Collection~deleteWriteOpResult
936
+ * @property {Object } result The raw result returned from MongoDB, field will vary depending on server version.
937
+ * @property {Number } result.ok Is 1 if the command executed correctly.
938
+ * @property {Number } result.n The total count of documents deleted.
939
+ * @property {Object } connection The connection object used for the operation.
940
+ * @property {Number } deletedCount The number of documents deleted.
941
+ */
942
+
943
+ /**
944
+ * The callback format for inserts
945
+ * @callback Collection~deleteWriteOpCallback
946
+ * @param {MongoError } error An error instance representing the error during the execution.
947
+ * @param {Collection~deleteWriteOpResult } result The result object if the command was executed successfully.
948
+ */
949
+
895
950
/**
896
951
* Delete a document on MongoDB
897
952
* @method
@@ -900,7 +955,7 @@ define.classMethod('update', {callback: true, promise:true});
900
955
* @param {(number|string) } [options.w=null] The write concern.
901
956
* @param {number } [options.wtimeout=null] The write concern timeout.
902
957
* @param {boolean } [options.j=false] Specify a journal write concern.
903
- * @param {Collection~writeOpCallback } [callback] The command result callback
958
+ * @param {Collection~deleteWriteOpCallback } [callback] The command result callback
904
959
* @return {Promise } returns Promise if no callback passed
905
960
*/
906
961
Collection . prototype . deleteOne = function ( filter , options , callback ) {
@@ -945,7 +1000,7 @@ define.classMethod('removeOne', {callback: true, promise:true});
945
1000
* @param {(number|string) } [options.w=null] The write concern.
946
1001
* @param {number } [options.wtimeout=null] The write concern timeout.
947
1002
* @param {boolean } [options.j=false] Specify a journal write concern.
948
- * @param {Collection~writeOpCallback } [callback] The command result callback
1003
+ * @param {Collection~deleteWriteOpCallback } [callback] The command result callback
949
1004
* @return {Promise } returns Promise if no callback passed
950
1005
*/
951
1006
Collection . prototype . deleteMany = function ( filter , options , callback ) {
@@ -1056,6 +1111,7 @@ define.classMethod('remove', {callback: true, promise:true});
1056
1111
* @param {boolean } [options.j=false] Specify a journal write concern.
1057
1112
* @param {Collection~writeOpCallback } [callback] The command result callback
1058
1113
* @return {Promise } returns Promise if no callback passed
1114
+ * @deprecated use insertOne, insertMany, updateOne or updateMany
1059
1115
*/
1060
1116
Collection . prototype . save = function ( doc , options , callback ) {
1061
1117
var self = this ;
@@ -1879,6 +1935,20 @@ var stats = function(self, options, callback) {
1879
1935
1880
1936
define . classMethod ( 'stats' , { callback : true , promise :true } ) ;
1881
1937
1938
+ /**
1939
+ * @typedef {Object } Collection~findAndModifyWriteOpResult
1940
+ * @property {object } value Document returned from findAndModify command.
1941
+ * @property {object } lastErrorObject The raw lastErrorObject returned from the command.
1942
+ * @property {Number } ok Is 1 if the command executed correctly.
1943
+ */
1944
+
1945
+ /**
1946
+ * The callback format for inserts
1947
+ * @callback Collection~findAndModifyCallback
1948
+ * @param {MongoError } error An error instance representing the error during the execution.
1949
+ * @param {Collection~findAndModifyWriteOpResult } result The result object if the command was executed successfully.
1950
+ */
1951
+
1882
1952
/**
1883
1953
* Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
1884
1954
*
@@ -1888,7 +1958,7 @@ define.classMethod('stats', {callback: true, promise:true});
1888
1958
* @param {object } [options.projection=null] Limits the fields to return for all matching documents.
1889
1959
* @param {object } [options.sort=null] Determines which document the operation modifies if the query selects multiple documents.
1890
1960
* @param {number } [options.maxTimeMS=null] The maximum amount of time to allow the query to run.
1891
- * @param {Collection~resultCallback } [callback] The collection result callback
1961
+ * @param {Collection~findAndModifyCallback } [callback] The collection result callback
1892
1962
* @return {Promise } returns Promise if no callback passed
1893
1963
*/
1894
1964
Collection . prototype . findOneAndDelete = function ( filter , options , callback ) {
@@ -1937,7 +2007,7 @@ define.classMethod('findOneAndDelete', {callback: true, promise:true});
1937
2007
* @param {number } [options.maxTimeMS=null] The maximum amount of time to allow the query to run.
1938
2008
* @param {boolean } [options.upsert=false] Upsert the document if it does not exist.
1939
2009
* @param {boolean } [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true.
1940
- * @param {Collection~resultCallback } [callback] The collection result callback
2010
+ * @param {Collection~findAndModifyCallback } [callback] The collection result callback
1941
2011
* @return {Promise } returns Promise if no callback passed
1942
2012
*/
1943
2013
Collection . prototype . findOneAndReplace = function ( filter , replacement , options , callback ) {
@@ -1988,7 +2058,7 @@ define.classMethod('findOneAndReplace', {callback: true, promise:true});
1988
2058
* @param {number } [options.maxTimeMS=null] The maximum amount of time to allow the query to run.
1989
2059
* @param {boolean } [options.upsert=false] Upsert the document if it does not exist.
1990
2060
* @param {boolean } [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true.
1991
- * @param {Collection~resultCallback } [callback] The collection result callback
2061
+ * @param {Collection~findAndModifyCallback } [callback] The collection result callback
1992
2062
* @return {Promise } returns Promise if no callback passed
1993
2063
*/
1994
2064
Collection . prototype . findOneAndUpdate = function ( filter , update , options , callback ) {
0 commit comments