diff --git a/test/docs/discriminators.test.js b/test/docs/discriminators.test.js index ffcef2c0404..c4f9c2eb3d8 100644 --- a/test/docs/discriminators.test.js +++ b/test/docs/discriminators.test.js @@ -31,8 +31,8 @@ describe('discriminator docs', function () { db.close(done); }); - beforeEach(function (done) { - Event.remove({}, done); + beforeEach(function(done) { + Event.deleteMany({}, done); }); /** diff --git a/test/docs/promises.test.js b/test/docs/promises.test.js index a41894ba154..75118af0aa7 100644 --- a/test/docs/promises.test.js +++ b/test/docs/promises.test.js @@ -15,7 +15,7 @@ describe('promises docs', function () { }); beforeEach(function (done) { - Band.remove({}, done); + Band.deleteMany({}, done); }); after(function (done) { diff --git a/test/model.discriminator.querying.test.js b/test/model.discriminator.querying.test.js index e25ddce4883..11c4aedec6f 100644 --- a/test/model.discriminator.querying.test.js +++ b/test/model.discriminator.querying.test.js @@ -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 diff --git a/test/model.querying.test.js b/test/model.querying.test.js index 8aeaa605da8..7ab6ac599f3 100644 --- a/test/model.querying.test.js +++ b/test/model.querying.test.js @@ -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(); }); @@ -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(); }); @@ -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(); }); @@ -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); }); diff --git a/test/model.test.js b/test/model.test.js index faa27efd562..ec4d4dae2cf 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -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(); }); @@ -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(); @@ -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); @@ -1654,7 +1654,7 @@ describe('Model', function() { }); }); - describe('#remove()', function() { + describe.skip('#remove()', function() { var B; before(function() { @@ -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( @@ -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'}). diff --git a/test/model.update.test.js b/test/model.update.test.js index ff07511dfe7..fd4e42782b8 100644 --- a/test/model.update.test.js +++ b/test/model.update.test.js @@ -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) { diff --git a/test/query.middleware.test.js b/test/query.middleware.test.js index 34b3e9eefd3..78925d8d2f1 100644 --- a/test/query.middleware.test.js +++ b/test/query.middleware.test.js @@ -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); } diff --git a/test/query.test.js b/test/query.test.js index 090d15a2f13..0083e3626ae 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -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); @@ -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(); }); @@ -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); @@ -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); @@ -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); @@ -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) { @@ -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) { @@ -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) { diff --git a/test/schema.timestamps.test.js b/test/schema.timestamps.test.js index ce03dcd0607..49eb91ba326 100644 --- a/test/schema.timestamps.test.js +++ b/test/schema.timestamps.test.js @@ -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) { @@ -326,7 +326,7 @@ describe('schema options.timestamps', function() { }); after(function(done) { - Cat.remove({}, done); + return Cat.deleteMany({}); }); }); });