Skip to content

Commit f224f71

Browse files
committed
feat: remove "remove"
1 parent 3053951 commit f224f71

File tree

5 files changed

+12
-264
lines changed

5 files changed

+12
-264
lines changed

README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ require('mongodb').connect(uri, function (err, db) {
5252
- [find()](#find)
5353
- [findOne()](#findone)
5454
- [count()](#count)
55-
- [remove()](#remove)
5655
- [update()](#update)
5756
- [the update document](#the-update-document)
5857
- [options](#options)
@@ -193,17 +192,6 @@ mquery().count(match, function (err, number){
193192
})
194193
```
195194

196-
### remove()
197-
198-
Declares this query a _remove_ query. Optionally pass a match clause and / or callback. If a callback is passed the query is executed.
199-
200-
```js
201-
mquery().remove()
202-
mquery().remove(match)
203-
mquery().remove(callback)
204-
mquery().remove(match, function (err){})
205-
```
206-
207195
### update()
208196

209197
Declares this query an _update_ query. Optionally pass an update document, match clause, options or callback. If a callback is passed, the query is executed. To force execution without passing a callback, run `update(true)`.
@@ -910,7 +898,6 @@ This option is only valid for operations that write to the database:
910898
- `deleteMany()`
911899
- `findOneAndDelete()`
912900
- `findOneAndUpdate()`
913-
- `remove()`
914901
- `update()`
915902
- `updateOne()`
916903
- `updateMany()`
@@ -1103,7 +1090,6 @@ This option is only valid for operations that write to the database:
11031090
- `deleteMany()`
11041091
- `findOneAndDelete()`
11051092
- `findOneAndUpdate()`
1106-
- `remove()`
11071093
- `update()`
11081094
- `updateOne()`
11091095
- `updateMany()`
@@ -1185,7 +1171,6 @@ This option is only valid for operations that write to the database:
11851171
- `deleteMany()`
11861172
- `findOneAndDelete()`
11871173
- `findOneAndUpdate()`
1188-
- `remove()`
11891174
- `update()`
11901175
- `updateOne()`
11911176
- `updateMany()`

lib/collection/collection.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const methods = [
1111
'updateMany',
1212
'updateOne',
1313
'replaceOne',
14-
'remove',
1514
'count',
1615
'distinct',
1716
'findOneAndDelete',

lib/collection/node.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ class NodeCollection extends Collection {
9090
this.collection.deleteMany(match, options, cb);
9191
}
9292

93-
/**
94-
* remove(match, options, function(err[, result])
95-
*/
96-
remove(match, options, cb) {
97-
this.collection.remove(match, options, cb);
98-
}
99-
10093
/**
10194
* findOneAndDelete(match, options, function(err[, result])
10295
*/

lib/mquery.js

Lines changed: 3 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,6 @@ Query.prototype.hint = function() {
15571557
* - `deleteMany()`
15581558
* - `findOneAndDelete()`
15591559
* - `findOneAndUpdate()`
1560-
* - `remove()`
15611560
* - `update()`
15621561
* - `updateOne()`
15631562
* - `updateMany()`
@@ -1752,7 +1751,6 @@ Query.prototype.tailable = function() {
17521751
* - `deleteMany()`
17531752
* - `findOneAndDelete()`
17541753
* - `findOneAndUpdate()`
1755-
* - `remove()`
17561754
* - `update()`
17571755
* - `updateOne()`
17581756
* - `updateMany()`
@@ -1801,7 +1799,6 @@ Query.prototype.writeConcern = Query.prototype.w = function writeConcern(concern
18011799
* - `deleteMany()`
18021800
* - `findOneAndDelete()`
18031801
* - `findOneAndUpdate()`
1804-
* - `remove()`
18051802
* - `update()`
18061803
* - `updateOne()`
18071804
* - `updateMany()`
@@ -2496,75 +2493,7 @@ function _update(query, op, criteria, doc, options, force, callback) {
24962493
}
24972494

24982495
/**
2499-
* Declare and/or execute this query as a remove() operation.
2500-
*
2501-
* #### Example:
2502-
*
2503-
* mquery(collection).remove({ artist: 'Anne Murray' }, callback)
2504-
*
2505-
* #### Note:
2506-
*
2507-
* The operation is only executed when a callback is passed. To force execution without a callback (which would be an unsafe write), we must first call remove() and then execute it by using the `exec()` method.
2508-
*
2509-
* // not executed
2510-
* var query = mquery(collection).remove({ name: 'Anne Murray' })
2511-
*
2512-
* // executed
2513-
* mquery(collection).remove({ name: 'Anne Murray' }, callback)
2514-
* mquery(collection).remove({ name: 'Anne Murray' }).remove(callback)
2515-
*
2516-
* // executed without a callback (unsafe write)
2517-
* query.exec()
2518-
*
2519-
* // summary
2520-
* query.remove(conds, fn); // executes
2521-
* query.remove(conds)
2522-
* query.remove(fn) // executes
2523-
* query.remove()
2524-
*
2525-
* @param {Object|Query} [criteria] mongodb selector
2526-
* @param {Function} [callback]
2527-
* @return {Query} this
2528-
* @api public
2529-
*/
2530-
2531-
Query.prototype.remove = function(criteria, callback) {
2532-
this.op = 'remove';
2533-
let force;
2534-
2535-
if ('function' === typeof criteria) {
2536-
callback = criteria;
2537-
criteria = undefined;
2538-
} else if (Query.canMerge(criteria)) {
2539-
this.merge(criteria);
2540-
} else if (true === criteria) {
2541-
force = criteria;
2542-
criteria = undefined;
2543-
}
2544-
2545-
if (!(force || callback))
2546-
return this;
2547-
2548-
const options = this._optionsForExec();
2549-
if (!callback) options.safe = false;
2550-
2551-
const conds = this._conditions;
2552-
2553-
debug('remove', this._collection.collectionName, conds, options);
2554-
callback = this._wrapCallback('remove', callback, {
2555-
conditions: conds,
2556-
options: options
2557-
});
2558-
2559-
this._collection.remove(conds, options, utils.tick(callback));
2560-
2561-
return this;
2562-
};
2563-
2564-
/**
2565-
* Declare and/or execute this query as a `deleteOne()` operation. Behaves like
2566-
* `remove()`, except for ignores the `justOne` option and always deletes at
2567-
* most one document.
2496+
* Declare and/or execute this query as a `deleteOne()` operation.
25682497
*
25692498
* #### Example:
25702499
*
@@ -2611,8 +2540,7 @@ Query.prototype.deleteOne = function(criteria, callback) {
26112540
};
26122541

26132542
/**
2614-
* Declare and/or execute this query as a `deleteMany()` operation. Behaves like
2615-
* `remove()`, except for ignores the `justOne` option and always deletes
2543+
* Declare and/or execute this query as a `deleteMany()` operation. Always deletes
26162544
* _every_ document that matches `criteria`.
26172545
*
26182546
* #### Example:
@@ -2879,7 +2807,7 @@ Query.prototype.exec = function exec(op, callback) {
28792807

28802808
assert.ok(this.op, 'Missing query type: (find, update, etc)');
28812809

2882-
if ('update' == this.op || 'remove' == this.op) {
2810+
if ('update' == this.op) {
28832811
callback || (callback = true);
28842812
}
28852813

0 commit comments

Comments
 (0)