@@ -350,7 +350,7 @@ Collection.prototype.find = function() {
350
350
* @param {boolean } [options.j=false] Specify a journal write concern.
351
351
* @param {boolean } [options.serializeFunctions=false] Serialize functions on any object.
352
352
* @param {boolean } [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
353
- * @param {Collection~writeOpCallback } [callback] The command result callback
353
+ * @param {Collection~insertWriteOpCallback } [callback] The command result callback
354
354
* @return {Promise } returns Promise if no callback passed
355
355
*/
356
356
Collection . prototype . insertOne = function ( doc , options , callback ) {
@@ -413,7 +413,7 @@ var mapInserManyResults = function(docs, r) {
413
413
* @param {boolean } [options.j=false] Specify a journal write concern.
414
414
* @param {boolean } [options.serializeFunctions=false] Serialize functions on any object.
415
415
* @param {boolean } [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
416
- * @param {Collection~writeOpCallback } [callback] The command result callback
416
+ * @param {Collection~insertWriteOpCallback } [callback] The command result callback
417
417
* @return {Promise } returns Promise if no callback passed
418
418
*/
419
419
Collection . prototype . insertMany = function ( docs , options , callback ) {
@@ -641,6 +641,24 @@ var insertDocuments = function(self, docs, options, callback) {
641
641
* @param {Collection~WriteOpResult } result The result object if the command was executed successfully.
642
642
*/
643
643
644
+ /**
645
+ * @typedef {Object } Collection~insertWriteOpResult
646
+ * @property {Number } insertedCount The total amount of documents inserted.
647
+ * @property {object[] } ops All the documents inserted using insertOne/insertMany/replaceOne. Documents contain the _id field if forceServerObjectId == false for insertOne/insertMany
648
+ * @property {ObjectId[] } insertedIds All the generated _id's for the inserted documents.
649
+ * @property {object } connection The connection object used for the operation.
650
+ * @property {object } result The raw command result object returned from MongoDB (content might vary by server version).
651
+ * @property {Number } result.ok Is 1 if the command executed correctly.
652
+ * @property {Number } result.n The total count of documents inserted.
653
+ */
654
+
655
+ /**
656
+ * The callback format for inserts
657
+ * @callback Collection~insertWriteOpCallback
658
+ * @param {MongoError } error An error instance representing the error during the execution.
659
+ * @param {Collection~insertWriteOpResult } result The result object if the command was executed successfully.
660
+ */
661
+
644
662
/**
645
663
* Inserts a single document or a an array of documents into MongoDB.
646
664
* @method
@@ -651,7 +669,7 @@ var insertDocuments = function(self, docs, options, callback) {
651
669
* @param {boolean } [options.j=false] Specify a journal write concern.
652
670
* @param {boolean } [options.serializeFunctions=false] Serialize functions on any object.
653
671
* @param {boolean } [options.forceServerObjectId=false] Force server to assign _id values instead of driver.
654
- * @param {Collection~writeOpCallback } [callback] The command result callback
672
+ * @param {Collection~insertWriteOpCallback } [callback] The command result callback
655
673
* @return {Promise } returns Promise if no callback passed
656
674
* @deprecated Use insertOne, insertMany or bulkWrite
657
675
*/
@@ -668,6 +686,27 @@ Collection.prototype.insert = function(docs, options, callback) {
668
686
return this . insertMany ( docs , options , callback ) ;
669
687
}
670
688
689
+ /**
690
+ * @typedef {Object } Collection~updateWriteOpResult
691
+ * @property {Object } result The raw result returned from MongoDB, field will vary depending on server version.
692
+ * @property {Number } result.ok Is 1 if the command executed correctly.
693
+ * @property {Number } result.n The total count of documents scanned.
694
+ * @property {Number } result.nModified The total count of documents modified.
695
+ * @property {Object } connection The connection object used for the operation.
696
+ * @property {Number } matchedCount The number of documents that matched the filter.
697
+ * @property {Number } modifiedCount The number of documents that were modified.
698
+ * @property {Number } upsertedCount The number of documents upserted.
699
+ * @property {Object } upsertedId The upserted id.
700
+ * @property {ObjectId } upsertedId._id The upserted _id returned from the server.
701
+ */
702
+
703
+ /**
704
+ * The callback format for inserts
705
+ * @callback Collection~updateWriteOpCallback
706
+ * @param {MongoError } error An error instance representing the error during the execution.
707
+ * @param {Collection~updateWriteOpResult } result The result object if the command was executed successfully.
708
+ */
709
+
671
710
/**
672
711
* Update a single document on MongoDB
673
712
* @method
@@ -678,7 +717,7 @@ Collection.prototype.insert = function(docs, options, callback) {
678
717
* @param {(number|string) } [options.w=null] The write concern.
679
718
* @param {number } [options.wtimeout=null] The write concern timeout.
680
719
* @param {boolean } [options.j=false] Specify a journal write concern.
681
- * @param {Collection~writeOpCallback } [callback] The command result callback
720
+ * @param {Collection~updateWriteOpCallback } [callback] The command result callback
682
721
* @return {Promise } returns Promise if no callback passed
683
722
*/
684
723
Collection . prototype . updateOne = function ( filter , update , options , callback ) {
@@ -724,7 +763,7 @@ var updateOne = function(self, filter, update, options, callback) {
724
763
* @param {(number|string) } [options.w=null] The write concern.
725
764
* @param {number } [options.wtimeout=null] The write concern timeout.
726
765
* @param {boolean } [options.j=false] Specify a journal write concern.
727
- * @param {Collection~writeOpCallback } [callback] The command result callback
766
+ * @param {Collection~updateWriteOpCallback } [callback] The command result callback
728
767
* @return {Promise } returns Promise if no callback passed
729
768
*/
730
769
Collection . prototype . replaceOne = function ( filter , update , options , callback ) {
@@ -771,7 +810,7 @@ var replaceOne = function(self, filter, update, options, callback) {
771
810
* @param {(number|string) } [options.w=null] The write concern.
772
811
* @param {number } [options.wtimeout=null] The write concern timeout.
773
812
* @param {boolean } [options.j=false] Specify a journal write concern.
774
- * @param {Collection~writeOpCallback } [callback] The command result callback
813
+ * @param {Collection~updateWriteOpCallback } [callback] The command result callback
775
814
* @return {Promise } returns Promise if no callback passed
776
815
*/
777
816
Collection . prototype . updateMany = function ( filter , update , options , callback ) {
@@ -871,6 +910,22 @@ Collection.prototype.update = function(selector, document, options, callback) {
871
910
} ) ;
872
911
}
873
912
913
+ /**
914
+ * @typedef {Object } Collection~deleteWriteOpResult
915
+ * @property {Object } result The raw result returned from MongoDB, field will vary depending on server version.
916
+ * @property {Number } result.ok Is 1 if the command executed correctly.
917
+ * @property {Number } result.n The total count of documents deleted.
918
+ * @property {Object } connection The connection object used for the operation.
919
+ * @property {Number } deletedCount The number of documents deleted.
920
+ */
921
+
922
+ /**
923
+ * The callback format for inserts
924
+ * @callback Collection~deleteWriteOpCallback
925
+ * @param {MongoError } error An error instance representing the error during the execution.
926
+ * @param {Collection~deleteWriteOpResult } result The result object if the command was executed successfully.
927
+ */
928
+
874
929
/**
875
930
* Delete a document on MongoDB
876
931
* @method
@@ -879,7 +934,7 @@ Collection.prototype.update = function(selector, document, options, callback) {
879
934
* @param {(number|string) } [options.w=null] The write concern.
880
935
* @param {number } [options.wtimeout=null] The write concern timeout.
881
936
* @param {boolean } [options.j=false] Specify a journal write concern.
882
- * @param {Collection~writeOpCallback } [callback] The command result callback
937
+ * @param {Collection~deleteWriteOpCallback } [callback] The command result callback
883
938
* @return {Promise } returns Promise if no callback passed
884
939
*/
885
940
Collection . prototype . deleteOne = function ( filter , options , callback ) {
@@ -920,7 +975,7 @@ Collection.prototype.removeOne = Collection.prototype.deleteOne;
920
975
* @param {(number|string) } [options.w=null] The write concern.
921
976
* @param {number } [options.wtimeout=null] The write concern timeout.
922
977
* @param {boolean } [options.j=false] Specify a journal write concern.
923
- * @param {Collection~writeOpCallback } [callback] The command result callback
978
+ * @param {Collection~deleteWriteOpCallback } [callback] The command result callback
924
979
* @return {Promise } returns Promise if no callback passed
925
980
*/
926
981
Collection . prototype . deleteMany = function ( filter , options , callback ) {
@@ -1025,6 +1080,7 @@ Collection.prototype.remove = function(selector, options, callback) {
1025
1080
* @param {boolean } [options.j=false] Specify a journal write concern.
1026
1081
* @param {Collection~writeOpCallback } [callback] The command result callback
1027
1082
* @return {Promise } returns Promise if no callback passed
1083
+ * @deprecated use insertOne, insertMany, updateOne or updateMany
1028
1084
*/
1029
1085
Collection . prototype . save = function ( doc , options , callback ) {
1030
1086
var self = this ;
@@ -1808,6 +1864,20 @@ var stats = function(self, options, callback) {
1808
1864
self . s . db . command ( commandObject , options , callback ) ;
1809
1865
}
1810
1866
1867
+ /**
1868
+ * @typedef {Object } Collection~findAndModifyWriteOpResult
1869
+ * @property {object } value Document returned from findAndModify command.
1870
+ * @property {object } lastErrorObject The raw lastErrorObject returned from the command.
1871
+ * @property {Number } ok Is 1 if the command executed correctly.
1872
+ */
1873
+
1874
+ /**
1875
+ * The callback format for inserts
1876
+ * @callback Collection~findAndModifyCallback
1877
+ * @param {MongoError } error An error instance representing the error during the execution.
1878
+ * @param {Collection~findAndModifyWriteOpResult } result The result object if the command was executed successfully.
1879
+ */
1880
+
1811
1881
/**
1812
1882
* Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
1813
1883
*
@@ -1817,7 +1887,7 @@ var stats = function(self, options, callback) {
1817
1887
* @param {object } [options.projection=null] Limits the fields to return for all matching documents.
1818
1888
* @param {object } [options.sort=null] Determines which document the operation modifies if the query selects multiple documents.
1819
1889
* @param {number } [options.maxTimeMS=null] The maximum amount of time to allow the query to run.
1820
- * @param {Collection~resultCallback } [callback] The collection result callback
1890
+ * @param {Collection~findAndModifyCallback } [callback] The collection result callback
1821
1891
* @return {Promise } returns Promise if no callback passed
1822
1892
*/
1823
1893
Collection . prototype . findOneAndDelete = function ( filter , options , callback ) {
@@ -1864,7 +1934,7 @@ var findOneAndDelete = function(self, filter, options, callback) {
1864
1934
* @param {number } [options.maxTimeMS=null] The maximum amount of time to allow the query to run.
1865
1935
* @param {boolean } [options.upsert=false] Upsert the document if it does not exist.
1866
1936
* @param {boolean } [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true.
1867
- * @param {Collection~resultCallback } [callback] The collection result callback
1937
+ * @param {Collection~findAndModifyCallback } [callback] The collection result callback
1868
1938
* @return {Promise } returns Promise if no callback passed
1869
1939
*/
1870
1940
Collection . prototype . findOneAndReplace = function ( filter , replacement , options , callback ) {
@@ -1913,7 +1983,7 @@ var findOneAndReplace = function(self, filter, replacement, options, callback) {
1913
1983
* @param {number } [options.maxTimeMS=null] The maximum amount of time to allow the query to run.
1914
1984
* @param {boolean } [options.upsert=false] Upsert the document if it does not exist.
1915
1985
* @param {boolean } [options.returnOriginal=true] When false, returns the updated document rather than the original. The default is true.
1916
- * @param {Collection~resultCallback } [callback] The collection result callback
1986
+ * @param {Collection~findAndModifyCallback } [callback] The collection result callback
1917
1987
* @return {Promise } returns Promise if no callback passed
1918
1988
*/
1919
1989
Collection . prototype . findOneAndUpdate = function ( filter , update , options , callback ) {
0 commit comments