2018-11-27 mongodb + noejs select fields on a collection

原因在于 _class 字段 使用 false标注了,删除即可:

    rs = await mongo.toutiaoqueryAll(match, 'tianyi', "campaign_info", conf.mongo.toutiaodb, {
        projection: {
            "_id": false,
"_class": false,
            "id": true,
            "advertiser_id": true,
            "name": true,
        }
    });
 express:router dispatching GET /navigateInfo?adverid=103780292228 +0ms
  cpctest match:{"adverid":103780292228} +2ms
(node:94336) UnhandledPromiseRejectionWarning: MongoError: Projection cannot have a mix of inclusion and exclusion.
    at queryCallback (F:\nodejs\node_global\node_modules\mongodb\node_modules\mongodb-core\lib\cursor.js:248:25)
    at F:\nodejs\node_global\node_modules\mongodb\node_modules\mongodb-core\lib\connection\pool.js:532:18
    at process._tickCallback (internal/process/next_tick.js:61:11)
(node:94336) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an
async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:94336) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。