Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
Replace deprecated collection methods mongodb-backend.js. Fixes Optim…
Browse files Browse the repository at this point in the history
  • Loading branch information
bazconz committed Oct 6, 2018
1 parent 7d151fd commit 89b8541
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/mongodb-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ MongoDBBackend.prototype = {
values.forEach(function(value){doc[value]=true;});

// update document
collection.update(updateParams,{$set:doc},{safe:true,upsert:true},function(err){
collection.updateOne(updateParams, {$set:doc}, {w:1, upsert:true}, function(err){
if(err instanceof Error) return cb(err);
cb(undefined);
});
Expand All @@ -135,7 +135,7 @@ MongoDBBackend.prototype = {
transaction.push(function(cb) {
self.db.collection(self.prefix + self.removeUnsupportedChar(collName), function(err,collection){
// Create index
collection.ensureIndex({_bucketname: 1, key: 1}, function(err){
collection.createIndex({_bucketname: 1, key: 1}, function(err){
if (err instanceof Error) {
return cb(err);
} else{
Expand All @@ -161,7 +161,7 @@ MongoDBBackend.prototype = {
transaction.push(function(cb){
self.db.collection(self.prefix + self.removeUnsupportedChar(collName),function(err,collection){
if(err instanceof Error) return cb(err);
collection.remove(updateParams,{safe:true},function(err){
collection.deleteMany(updateParams, {w:1}, function(err){
if(err instanceof Error) return cb(err);
cb(undefined);
});
Expand Down Expand Up @@ -191,7 +191,7 @@ MongoDBBackend.prototype = {
values.forEach(function(value){doc[value]=true;});

// update document
collection.update(updateParams,{$unset:doc},{safe:true,upsert:true},function(err){
collection.updateOne(updateParams, {$unset:doc}, {w:1, upsert:true}, function(err){
if(err instanceof Error) return cb(err);
cb(undefined);
});
Expand Down

0 comments on commit 89b8541

Please sign in to comment.