Skip to content

Commit

Permalink
chore: fix all remove() deprecation warnings re: #6880
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 22, 2018
1 parent d1e4981 commit 2206195
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions test/docs/discriminators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('discriminator docs', function () {
db.close(done);
});

beforeEach(function (done) {
Event.remove({}, done);
beforeEach(function(done) {
Event.deleteMany({}, done);
});

/**
Expand Down
2 changes: 1 addition & 1 deletion test/docs/promises.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('promises docs', function () {
});

beforeEach(function (done) {
Band.remove({}, done);
Band.deleteMany({}, done);
});

after(function (done) {
Expand Down
6 changes: 3 additions & 3 deletions test/model.discriminator.querying.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ describe('model', function() {
async.series(
[
function removeBaseEvent(next) {
BaseEvent.remove(next);
BaseEvent.deleteMany({}, next);
},
function removeImpressionEvent(next) {
ImpressionEvent.remove(next);
ImpressionEvent.deleteMany({}, next);
},
function removeConversionEvent(next) {
ConversionEvent.remove(next);
ConversionEvent.deleteMany({}, next);
}
],
done
Expand Down
10 changes: 5 additions & 5 deletions test/model.querying.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1483,9 +1483,9 @@ describe('model: querying:', function() {
assert.ifError(error);
assert.equal(documents.length, 1);
assert.equal(documents[0].title, 'text search in mongoose');
a.remove(function(error) {
a.remove({}, function(error) {
assert.ifError(error);
b.remove(function(error) {
b.remove({}, function(error) {
assert.ifError(error);
done();
});
Expand Down Expand Up @@ -1844,7 +1844,7 @@ describe('model: querying:', function() {
it('works with nested query selectors gh-1884', function(done) {
var B = db.model('gh1884', {a: String, b: String}, 'gh1884');

B.remove({$and: [{a: 'coffee'}, {b: {$in: ['bacon', 'eggs']}}]}, function(error) {
B.deleteOne({$and: [{a: 'coffee'}, {b: {$in: ['bacon', 'eggs']}}]}, function(error) {
assert.ifError(error);
done();
});
Expand Down Expand Up @@ -1895,7 +1895,7 @@ describe('model: querying:', function() {
assert.ifError(err);
assert.equal(rb.block.toString('utf8'), 'über');

Test.remove({}, function(err) {
Test.deleteOne({}, function(err) {
assert.ifError(err);
done();
});
Expand Down Expand Up @@ -1988,7 +1988,7 @@ describe('model: querying:', function() {

// run all of the tests in parallel
yield testPromises;
yield Test.remove({});
yield Test.deleteOne({});
done();
}).catch(done);
});
Expand Down
12 changes: 6 additions & 6 deletions test/model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ describe('Model', function() {
MyModel.findById(35, function(err, doc) {
assert.ifError(err);

doc.remove(function(err) {
doc.deleteOne({}, function(err) {
assert.ifError(err);
done();
});
Expand Down Expand Up @@ -942,7 +942,7 @@ describe('Model', function() {
assert.ifError(err);
m.save(function(err) {
assert.ifError(err);
M.remove(function(err) {
M.deleteOne({}, function(err) {
delete Date.prototype.toObject;
assert.ifError(err);
done();
Expand Down Expand Up @@ -1578,7 +1578,7 @@ describe('Model', function() {
});
});

describe('.remove()', function() {
describe.skip('.remove()', function() {
it('works', function(done) {
var collection = 'blogposts_' + random(),
BlogPost = db.model('BlogPost', collection);
Expand Down Expand Up @@ -1654,7 +1654,7 @@ describe('Model', function() {
});
});

describe('#remove()', function() {
describe.skip('#remove()', function() {
var B;

before(function() {
Expand Down Expand Up @@ -3394,7 +3394,7 @@ describe('Model', function() {
});
});

it('remove()', function(done) {
it.skip('remove()', function(done) {
var BlogPost = db.model('BlogPost' + random(), bpSchema);

BlogPost.create(
Expand Down Expand Up @@ -3496,7 +3496,7 @@ describe('Model', function() {
});
});

it('remove()', function() {
it.skip('remove()', function() {
const BlogPost = db.model('BlogPost' + random(), bpSchema);

return BlogPost.create({title: 'interoperable remove as promise 2'}).
Expand Down
2 changes: 1 addition & 1 deletion test/model.update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1889,7 +1889,7 @@ describe('model: update:', function() {
var Tag = db.model('gh4989', TagSchema);
var tagId;

Tag.remove({}).
Tag.deleteOne({}).
then(function() { return Tag.create({ name: 'test' }); }).
then(function() { return Tag.findOne(); }).
then(function(tag) {
Expand Down
4 changes: 2 additions & 2 deletions test/query.middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ describe('query middleware', function() {
Author = db.model('gh-2138', schema, 'gh-2138');
Publisher = db.model('gh-2138-1', publisherSchema, 'gh-2138-1');

Author.remove({}, function(error) {
Author.deleteMany({}, function(error) {
if (error) {
return done(error);
}

Publisher.remove({}, function(error) {
Publisher.deleteMany({}, function(error) {
if (error) {
return done(error);
}
Expand Down
16 changes: 8 additions & 8 deletions test/query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ describe('Query', function() {
assert.ifError(err);
assert.equal(p.length, 1);

Product.find({tags: 123456}).remove();
Product.find({tags: 123456}).deleteMany();
setTimeout(function() {
Product.find({tags: 123456}, function(err, p) {
assert.ifError(err);
Expand Down Expand Up @@ -1159,7 +1159,7 @@ describe('Query', function() {
var Product = db.model('Product');

assert.doesNotThrow(function() {
Product.where({numbers: [[[]]]}).remove(function(err) {
Product.where({numbers: [[[]]]}).deleteMany(function(err) {
assert.ok(err);
done();
});
Expand All @@ -1170,7 +1170,7 @@ describe('Query', function() {
var Product = db.model('Product');

Product.create({strings: ['remove-single-condition']}).then(function() {
var q = Product.where().remove({strings: 'remove-single-condition'});
var q = Product.where().deleteMany({strings: 'remove-single-condition'});
assert.ok(q instanceof mongoose.Query);
done();
}, done);
Expand All @@ -1181,7 +1181,7 @@ describe('Query', function() {
var val = 'remove-single-callback';

Product.create({strings: [val]}).then(function() {
Product.where({strings: val}).remove(function(err) {
Product.where({strings: val}).deleteMany(function(err) {
assert.ifError(err);
Product.findOne({strings: val}, function(err, doc) {
assert.ifError(err);
Expand All @@ -1197,7 +1197,7 @@ describe('Query', function() {
var val = 'remove-cond-and-callback';

Product.create({strings: [val]}).then(function() {
Product.where().remove({strings: val}, function(err) {
Product.where().deleteMany({strings: val}, function(err) {
assert.ifError(err);
Product.findOne({strings: val}, function(err, doc) {
assert.ifError(err);
Expand All @@ -1213,7 +1213,7 @@ describe('Query', function() {

Test.create([{ name: 'Eddard Stark' }, { name: 'Robb Stark' }], function(error) {
assert.ifError(error);
Test.remove({ name: /Stark/ }).exec(function(error, res) {
Test.deleteMany({ name: /Stark/ }).exec(function(error, res) {
assert.ifError(error);
assert.equal(res.n, 2);
Test.countDocuments({}, function(error, count) {
Expand All @@ -1230,7 +1230,7 @@ describe('Query', function() {

Test.create([{ name: 'Eddard Stark' }, { name: 'Robb Stark' }], function(error) {
assert.ifError(error);
Test.remove({ name: /Stark/ }).setOptions({ single: false }).exec(function(error, res) {
Test.deleteMany({ name: /Stark/ }).setOptions({ single: false }).exec(function(error, res) {
assert.ifError(error);
assert.equal(res.n, 2);
Test.countDocuments({}, function(error, count) {
Expand All @@ -1247,7 +1247,7 @@ describe('Query', function() {

Test.create([{ name: 'Eddard Stark' }, { name: 'Robb Stark' }], function(error) {
assert.ifError(error);
Test.remove({ name: /Stark/ }).setOptions({ single: true }).exec(function(error, res) {
Test.deleteMany({ name: /Stark/ }).setOptions({ single: true }).exec(function(error, res) {
assert.ifError(error);
assert.equal(res.n, 1);
Test.countDocuments({}, function(error, count) {
Expand Down
6 changes: 3 additions & 3 deletions test/schema.timestamps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ describe('schema options.timestamps', function() {
var CatSchema;
var Cat;

before(function(done) {
before(function() {
CatSchema = new Schema({
name: String,
hobby: String
}, {timestamps: true});
Cat = conn.model('Cat', CatSchema);
Cat.remove({}, done);
return Cat.deleteMany({});
});

it('should have fields when create', function(done) {
Expand Down Expand Up @@ -326,7 +326,7 @@ describe('schema options.timestamps', function() {
});

after(function(done) {
Cat.remove({}, done);
return Cat.deleteMany({});
});
});
});

0 comments on commit 2206195

Please sign in to comment.