gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 10:33:58 27 4
gpt4 key购买 nike

我收到此错误消息:

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

最佳答案

试试这个:

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

关于mongodb - 如何在 mongoskin 中设置安全变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13335379/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com