流星:我如何从特定对象的字段中返回数据? [英] Meteor: how do I return data from fields in a specific object?
问题描述
$ b
myobject
具有各种属性, _id,name,createdBy,date
etc
在我的find查询中,我只想从myObject中返回特定的字段。所以,例如,我需要做些什么来修改下面的find查询,以便只返回 name
?
myCollection.find({createdBy:someId},{fields:{myObject:1}})。fetch();
目前这将返回 myObject
中的所有内容它应该这样做,我只是希望在 myObject
中的一个字段返回。
这是在查询中执行的一种方法:
1}})。fetch();
$ b
'myObject.name'
This should be a fairly simple one.
myobject
has various properties, _id, name, createdBy, date
etc
In my find query I want to only return specific fields from within myObject. So for example, what would I need to do to modify the find query below so that only name
was returned?
myCollection.find({createdBy: someId}, {fields: {myObject: 1}}).fetch();
Currently this will return everything in myObject
which it should do, I just want one field within myObject
returned.
Here is a way to do it within the query:
myCollection.find({createdBy: someId}, {fields: {'myObject.name': 1}}).fetch();
Note the quotes around
'myObject.name'
这篇关于流星:我如何从特定对象的字段中返回数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!