【问题标题】:Using $ne Mongo operator on subdocuments in Meteor still returns the full collection在 Meteor 的子文档上使用 $ne Mongo 运算符仍会返回完整集合
【发布时间】:2023-04-09 07:41:01
【问题描述】:

我已经创建了一个这样的测试数据库:

Test.insert({_id: "XJAGgP3whnNd2HZec"}) ;
Test.insert({_id: "user1"} );
Test.insert({_id: "user8"} );
Test.insert({_id: "user5"}) ;

Test.update({_id: "XJAGgP3whnNd2HZec"}, {
$push: { users:{name8: "test5"}} });
Test.update({_id: "user5"}, {
$push: { users:{name8: "test5"}} });
Test.update({_id: "user8"}, {
$push: { users:{name9: "test5"}} });
Test.update({_id: "user1"}, {
$push: { users:{name9: "test4"}} }) ;

从流星蒙戈我可以搜索结果。例如:

> db.test.find({'users.name9': "test4"}).count()
1
> db.test.find({'users.name9': {$ne: "test4"}}).count()
3
>

如果我在 Meteor 中输入相同的查询。例如:

console.log(Test.find({'users.name9': { $ne: "test4" } }) ),

Meteor 返回一个包含所有条目的集合对象。

我在这里遗漏了什么明显的东西吗?

【问题讨论】:

标签: mongodb meteor


【解决方案1】:

我意识到我最初问题中的逻辑不太正确。

我提出了一张现已修复的票:

这张票更清楚:https://github.com/meteor/meteor/issues/1451

【讨论】:

    【解决方案2】:

    我也试过了,对我来说效果很好。我不知道你的问题是什么,但我会尝试meteor reset(它会刷新你的数据库,删除所有内容并重新开始),如果这不起作用,我会尝试创建一个新项目。如果您不想再次编写代码文件,可以将代码文件复制到新项目中。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 2019-08-27
    • 2022-01-14
    • 2021-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多