我正在尝试在本地运行 Node.js 脚本,但它给了我以下错误消息:
========================================================================================
= Please ensure that you set the default safe variable to one of the =
= allowed values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}] =
= the default value is false which means the driver receives does not =
= return the information of the success/error of the insert/update/remove =
= =
= ex: new Db(new Server('localhost', 27017), {safe:false}) =
= =
= http://www.mongodb.org/display/DOCS/getLastError+Command =
= =
= The default of false will change to true in the near future =
= =
= This message will disappear when the default safe is set on the driver Db =
========================================================================================
这是我的变量:
var express = require('express');
var mongodb = require('mongodb');
var GridStore = require('mongodb').GridStore;
var Db = require('mongodb').Db;
var Server = require('mongodb').Server;
var db = new Db(Config.dbName, new Server("127.0.0.1", 27017, {}), {});
var HttpGet = require('./httpGet').HttpGet;
var URL = require('url');
var dbClient = null; // this is initialized when db is opened
var app = module.exports = express();
相同的脚本在我的实时服务器上运行良好。仅当我在本地运行它时,它才会出现。
我发现 github 上正在讨论同样的问题,但没有找到解决方案。https://github.com/kissjs/node-mongoskin/issues/77 https://github.com/kissjs/node-mongoskin/issues/77
有谁知道什么可能导致这个问题?
提前致谢 :)
使用 1.1.11 mongo 驱动程序,以下内容适用于我:
var db = new Db(Config.dbName, new Server("127.0.0.1", 27017, {}), {safe: true});
如果没有{safe: true}
参数我确实得到了与您在问题中显示的相同的警告。
该警告是驱动程序最近添加的;您可能在服务器上使用旧版本的驱动程序,这就是您看不到警告的原因。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)