如何在mongoskin中设置安全变量?

时间:2012-11-11 20:57:14

标签: mongodb mongoskin

我收到此错误消息:

========================================================================================
=  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           =
========================================================================================

我找到了一种在本地MongoDB中处理它的方法,但有没有办法使用mongoskin设置安全变量?

澄清:我能够查询数据库并输出一个字符串,尽管有错误。但是,如果我想返回变量以便将它传递给另一个函数,我得到这个:

{ emitter: { _events: { open: [Object] }, _maxListeners: 50 },
  state: 1,
  options: undefined,
  skinDb:
   { emitter: { _events: [Object], _maxListeners: 100 },
     state: 1,
     _dbconn:
      { databaseName: 'titles',
    serverConfig: [Object],
    options: [Object],
    _applicationClosed: false,
    native_parser: true,
    bsonLib: [Object],
    bson: {},
    bson_deserializer: [Object],
    bson_serializer: [Object],
    _state: 'connecting',
    pkFactory: [Object],
    forceServerObjectId: false,
    safe: true,
    notReplied: {},
    isInitializing: true,
    auths: [],
    openCalled: true,
    commands: [],
    _callBackStore: [Object],
    logger: [Object],
    slaveOk: false,
    tag: 1352682584657,
    eventHandlers: [Object],
    serializeFunctions: false,
    raw: false,
    recordQueryStats: false,
    reaperEnabled: false,
    _lastReaperTimestamp: 1352682584657,
    retryMiliSeconds: 1000,
    numberOfRetries: 60,
    reaperInterval: 10000,
    reaperTimeout: 30000,
    readPreference: undefined },
 db: null,
 username: '',
 password: undefined,
 admin: { emitter: {}, state: 0, skinDb: [Circular], admin: null },
 _collections: { titles: [Circular] },
 bson_serializer:
  { BSON: [Object],
    Long: [Object],
    ObjectID: [Object],
    DBRef: [Function: DBRef],
    Code: [Function: Code],
    Timestamp: [Object],
    Binary: [Object],
    Double: [Function: Double],
    MaxKey: [Function: MaxKey],
    MinKey: [Function: MinKey],
    Symbol: [Function: Symbol] },
 ObjectID:
  { [Function: ObjectID]
    index: 0,
    createPk: [Function: createPk],
    createFromTime: [Function: createFromTime],
    createFromHexString: [Function: createFromHexString] } },
  ObjectID:
   { [Function: ObjectID]
 index: 0,
 createPk: [Function: createPk],
 createFromTime: [Function: createFromTime],
 createFromHexString: [Function: createFromHexString] },
  collectionName: 'titles',
  collection: null,
  internalHint: null,
  hint: [Getter/Setter] }

2 个答案:

答案 0 :(得分:2)

试试这个:

var db = mongoskin.db('localhost:27017/test', {safe: true});

答案 1 :(得分:0)

在官方mongoskin问题跟踪器中查看此页:https://github.com/kissjs/node-mongoskin/issues/77