猫鼬检索没有_id字段的数据 [英] Mongoose retrieving data without _id field

查看:61
本文介绍了猫鼬检索没有_id字段的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Node.js应用程序中的Mongoose设置中检索一些数据.我注意到无论我写什么作为字段选择,我总是得到_id字段.有没有一种方法不可以获取它? 我现在是这样的:

I would like to retrieve some data from a Mongoose setting in my Node.js application. I noticed that no matter what I write as field selection, I always get the _id field. Is there a way not to fetch it? This is how I do right now:

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字段的结果记录给我.

And logs me the results which contain the _id field.

推荐答案

_id.例如,

Transaction.find({username : user.username}, { '_id': 0, 'uniqueId' :1, 'timeout': 1, 'confirmation_link': 1, 'item_name': 1}, function(err, txs){
  console.log("user : " + user.username + " with txs: " + txs);
  callback(txs);
});

这篇关于猫鼬检索没有_id字段的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆