email: {"email":"aaa@bbb.eu"}
{ _mongooseOptions: {},
mongooseCollection:
{ collection:
{ db: [Object],
collectionName: 'parties',
internalHint: null,
opts: {},
slaveOk: false,
serializeFunctions: false,
raw: false,
pkFactory: [Object],
serverCapabilities: undefined },
opts: { bufferCommands: true, capped: false },
name: 'parties',
conn:
{ base: [Object],
collections: [Object],
models: [Object],
replica: false,
hosts: null,
host: 'localhost',
port: 27017,
user: undefined,
pass: undefined,
name: 'pluserDB',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: true,
_events: {},
db: [Object] },
queue: [],
buffer: false },
model:
{ [Function: model]
base:
{ connections: [Object],
plugins: [],
models: [Object],
modelSchemas: [Object],
options: [Object] },
modelName: 'Party',
model: [Function: model],
db:
{ base: [Object],
collections: [Object],
models: [Object],
replica: false,
hosts: null,
host: 'localhost',
port: 27017,
user: undefined,
pass: undefined,
name: 'pluserDB',
options: [Object],
otherDbs: [],
_readyState: 1,
_closeCalled: false,
_hasOpened: true,
_listening: true,
_events: {},
db: [Object] },
discriminators: undefined,
schema:
{ paths: [Object],
subpaths: {},
virtuals: [Object],
nested: {},
inherits: {},
callQueue: [],
_indexes: [],
methods: {},
statics: {},
tree: [Object],
_requiredpaths: undefined,
discriminatorMapping: undefined,
_indexedpaths: undefined,
options: [Object],
_events: {} },
options: undefined,
collection:
{ collection: [Object],
opts: [Object],
name: 'parties',
conn: [Object],
queue: [],
buffer: false } },
op: 'find',
options: {},
_conditions: { email: '{"email":"aaa@bbb.eu"}' },
_fields: { email: 1, _id: 0 },
_update: undefined,
_path: undefined,
_distinct: undefined,
_collection:
{ collection:
{ collection: [Object],
opts: [Object],
name: 'parties',
conn: [Object],
queue: [],
buffer: false },
collectionName: undefined },
_traceFunction: undefined,
_castError: null }
Run Code Online (Sandbox Code Playgroud)
请看下面的代码:
var parties = Party.find({ email: email }, { email: 1, _id: 0 });
Run Code Online (Sandbox Code Playgroud)
此查询返回 3 个文档。
现在我想发送结果并对这些文档进行字符串化:
response.json(parties);
Run Code Online (Sandbox Code Playgroud)
我在这里收到错误,因为parties
包含循环引用,而不仅仅是包含我在这里需要的纯数据。
问题是:
我如何find()
在这里对方法的结果进行字符串化?
我知道我的错误是什么。
MongoDB
而且它的shell和API不一样Mongoose
。
find()
方法需要两者不同的参数。
我这里需要的是:
Party.find({ 'email': email }, 'email', function (err, parties) { response.json(parties)});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
15030 次 |
最近记录: |