Node.js mongodb set default safe variable

前端 未结 3 1868
暗喜
暗喜 2021-02-19 14:48

I am trying to run a Node.js script locally and it\'s giving me this error message:

===============================================================         


        
相关标签:
3条回答
  • 2021-02-19 14:56

    I got it to work by setting the strict mode to false.

    var db = new Db(config.dbName, new Server("127.0.0.1", 27017, {}), {safe: false, strict: false}); 
    
    0 讨论(0)
  • 2021-02-19 15:02

    This worked for me!

    var db = new Db((new DbServer('127.0.0.1', 27017), {w:-2,journal:false,fsync:false,safe: false})
    
    0 讨论(0)
  • 2021-02-19 15:12

    The following works for me using the 1.1.11 mongo driver:

    var db = new Db(Config.dbName, new Server("127.0.0.1", 27017, {}), {safe: true});
    

    Without the {safe: true} parameter I do get the same warning as you show in your question.

    This warning was a very recent addition to the driver; you're probably using an older version of the driver on your server which is why you don't see the warning there.

    0 讨论(0)
提交回复
热议问题