Skip to content

Commit d808a54

Browse files
committed
BREAKING CHANGE: use mongooseCollection for all query operations
1 parent 2b9bb5d commit d808a54

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

lib/mongoose.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* Module dependencies.
55
*/
66

7-
require('./driver').set(require('./drivers/node-mongodb-native'));
8-
97
const Document = require('./document');
108
const EventEmitter = require('events').EventEmitter;
119
const Kareem = require('kareem');
@@ -1174,15 +1172,6 @@ Mongoose.prototype.CastError = require('./error/cast');
11741172

11751173
Mongoose.prototype.SchemaTypeOptions = require('./options/SchemaTypeOptions');
11761174

1177-
/**
1178-
* The [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) driver Mongoose uses.
1179-
*
1180-
* @property mongo
1181-
* @api public
1182-
*/
1183-
1184-
Mongoose.prototype.mongo = require('mongodb');
1185-
11861175
/**
11871176
* The [mquery](https://github.com/aheckmann/mquery) query builder Mongoose uses.
11881177
*

lib/query.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,7 @@ Query.prototype._find = async function _find() {
22692269
const filter = this._conditions;
22702270
const fields = options.projection;
22712271

2272-
const cursor = await this._collection.collection.find(filter, options);
2272+
const cursor = await this.mongooseCollection.find(filter, options);
22732273
if (options.explain) {
22742274
return cursor.explain();
22752275
}
@@ -2516,7 +2516,7 @@ Query.prototype._findOne = async function _findOne() {
25162516
this._applyTranslateAliases(options);
25172517

25182518
// don't pass in the conditions because we already merged them in
2519-
const doc = await this._collection.collection.findOne(this._conditions, options);
2519+
const doc = await this.mongooseCollection.findOne(this._conditions, options);
25202520
return new Promise((resolve, reject) => {
25212521
this._completeOne(doc, null, _wrapThunkCallback(this, (err, res) => {
25222522
if (err) {
@@ -2614,7 +2614,7 @@ Query.prototype._countDocuments = async function _countDocuments() {
26142614

26152615
const conds = this._conditions;
26162616

2617-
return this._collection.collection.countDocuments(conds, options);
2617+
return this.mongooseCollection.countDocuments(conds, options);
26182618
};
26192619

26202620
/*!
@@ -2659,7 +2659,7 @@ Query.prototype._estimatedDocumentCount = async function _estimatedDocumentCount
26592659

26602660
const options = this._optionsForExec();
26612661

2662-
return this._collection.collection.estimatedDocumentCount(options);
2662+
return this.mongooseCollection.estimatedDocumentCount(options);
26632663
};
26642664

26652665
/**
@@ -2780,7 +2780,7 @@ Query.prototype.__distinct = async function __distinct() {
27802780
const options = this._optionsForExec();
27812781
this._applyTranslateAliases(options);
27822782

2783-
return this._collection.collection.
2783+
return this.mongooseCollection.
27842784
distinct(this._distinct, this._conditions, options);
27852785
};
27862786

@@ -2998,7 +2998,7 @@ Query.prototype._deleteOne = async function _deleteOne() {
29982998
const options = this._optionsForExec();
29992999
this._applyTranslateAliases(options);
30003000

3001-
return this._collection.collection.deleteOne(this._conditions, options);
3001+
return this.mongooseCollection.deleteOne(this._conditions, options);
30023002
};
30033003

30043004
/**
@@ -3072,7 +3072,7 @@ Query.prototype._deleteMany = async function _deleteMany() {
30723072
const options = this._optionsForExec();
30733073
this._applyTranslateAliases(options);
30743074

3075-
return this._collection.collection.deleteMany(this._conditions, options);
3075+
return this.mongooseCollection.deleteMany(this._conditions, options);
30763076
};
30773077

30783078
/**
@@ -3326,7 +3326,7 @@ Query.prototype._findOneAndUpdate = async function _findOneAndUpdate() {
33263326
this._update = this._update.toBSON();
33273327
}
33283328

3329-
let res = await this._collection.collection.findOneAndUpdate(this._conditions, this._update, options);
3329+
let res = await this.mongooseCollection.findOneAndUpdate(this._conditions, this._update, options);
33303330
for (const fn of this._transforms) {
33313331
res = fn(res);
33323332
}
@@ -3422,7 +3422,7 @@ Query.prototype._findOneAndDelete = async function _findOneAndDelete() {
34223422
const options = this._optionsForExec(this.model);
34233423
this._applyTranslateAliases(options);
34243424

3425-
let res = await this._collection.collection.findOneAndDelete(filter, options);
3425+
let res = await this.mongooseCollection.findOneAndDelete(filter, options);
34263426
for (const fn of this._transforms) {
34273427
res = fn(res);
34283428
}
@@ -3576,7 +3576,7 @@ Query.prototype._findOneAndReplace = async function _findOneAndReplace() {
35763576
throw validationError;
35773577
}
35783578

3579-
let res = await this._collection.collection.findOneAndReplace(filter, this._update, options);
3579+
let res = await this.mongooseCollection.findOneAndReplace(filter, this._update, options);
35803580

35813581
for (const fn of this._transforms) {
35823582
res = fn(res);
@@ -3790,7 +3790,7 @@ async function _updateThunk(op) {
37903790
this._update = this._update.toBSON();
37913791
}
37923792

3793-
return this._collection.collection[op](castedQuery, this._update, options);
3793+
return this.mongooseCollection[op](castedQuery, this._update, options);
37943794
}
37953795

37963796
/**

0 commit comments

Comments
 (0)