0
我有這樣的代碼AngularJS流星蒙戈集合鍵值
$scope.users = $meteor.collection(function() {
return AllClients.find({}, {name: 1, _id: 0});
});
我期待回到這樣
/* 1 */
{
"name" : "Samsung"
}
/* 2 */
{
"name" : "HP"
}
值,但它仍然會返回這樣
/* 1 */
{
"_id" : "SqFP23zTXo6MqDLxP",
"code" : "A100",
"name" : "Samsung",
"address" : "Korea"
}
/* 2 */
{
"_id" : "8QtNBoBGrvv5wWpuZ",
"code" : "B100",
"name" : "HP",
"address" : "USA"
}
值
這是一個錯誤?或者編碼不好...
嘗試投影字段爲'var projection = {name:1,_id:0}; return AllClients.find({},{fields:projection});' – chridam
正如@chridam指出的那樣,您需要提供[字段說明符](http://docs.meteor.com/#/full/fieldspecifiers) ,而不僅僅是田野。你的代碼應該是find({},{fields:{/ * your fields * /}})'。 –
試過這個,但我得到一個遊標錯誤.... – locksalt