【发布时间】:2025-12-26 05:50:11
【问题描述】:
我正在尝试了解如何使用 mongo 并获取特定的结果集。我觉得有点傻,因为我在互联网上几乎找不到关于它究竟是如何工作的,这对大多数人来说一定是非常明显的。
如果它可以谷歌搜索,请帮助我找到正确的关键字,因为我无法通过该路线到达我需要到达的地方:)
Meteor.startup(function() {
Users.remove({}); //reset test
if (Users.find().count() === 0) {
Users.insert([
{username : 'Daan' , password : "test2"},
{username : 'Miranda', password : "test1"}
]);
console.log(Users.find({}).fetch());
console.log(Users.find({username : 'Daan'}).fetch());
}
});
使用 {username : 'Daan'} 的查找一无所获。 带有 ({}) 的查找返回数组中的两条记录
【问题讨论】:
-
docs.mongodb.org/manual/reference/method/db.collection.find 有大量手册,但我不会通过流星学习。从 mongo shell 开始。那将是 db.collectionname.find({username: 'Daan'})
标签: mongodb collections meteor