我想從我的Node.js應用程序中的Mongoose設置檢索一些數據。我注意到無論我作爲字段選擇寫什麼,我總是得到_id
字段。有沒有辦法取回它? 這是我該怎麼做現在:Mongoose檢索沒有_id字段的數據
Transaction.find({username : user.username}, ['uniqueId', 'timeout', 'confirmation_link', 'item_name'], function(err, txs){
console.log("user : " + user.username + " with txs: " + txs);
callback(txs);
});
,並記錄我這包含_id
場的結果。
你可以排除_id並仍然保持ID?我注意到id是一個虛擬的字段。我想要id,但在我的REST API中排除_id。現在,當我排除_id時,id變爲空 – diokey 2015-11-09 02:19:00