MongoDb仅返回所选文档中的一个字段

时间:2018-09-10 03:55:52

标签: mongodb

我正在尝试从集合中的文档中检索单个字段作为对象

有我的代码:

const field = await db
    .collection('mycollection')
    .find({
      itemid: 378
    })
    .project({ status: 1 });

    console.log("The field status is: " + field.status);

输出:

The field status is: undefined

0 个答案:

没有答案
相关问题