你好我想列出Mongodb上的所有收藏品,除了两个名为“logos”和“outlet”的收藏品,但我似乎无法弄明白。
这是代码
db.listCollections({name: {$ne: 'outlets'}}, {name: {$ne: 'logos'}}).toArray((err, docs) => {
console.log(docs)
if (err) {
return cb(err);
}
assert.equal(err, null);
return cb(null, docs);
});
}
答案 0 :(得分:1)
尝试这样的事情:
db.getCollectionNames().filter(name => ['logos','outlets'].indexOf(name) === -1)
也在你的查询中你可以:
db.listCollections({name: {$nin: ['outlets', 'logos']}}).toArray(...)
如果您需要查找或汇总(或其他任何内容),您可以这样做:
db.getCollection(YOUR_COLLECTION_NAME).find({})
监督大多数团队MongoDB 你可以安装Robo 3T(Robomongo),有可能连接到服务器