- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
假设文档如下:
{
"group_id": 1,
"group_token": "3bu48xp9ok5",
"group_passward": "0000",
"admin": "Forne",
"member": [
{
"mid": 1,
"Name": "Forne",
"Email": "xxx@xxx.com",
"Rank": "admin",
"sub": [
"test",
"xxx",
"Forne"
]
}
]
}
这是我的试用:
var collection = myDB.collection('test');
collection.update({"group_token":"3bu48xp9ok5"},{$pull:{"member.$[elem1].sub":"test"}}, {arrayFilters: [{"elem1.Email":"xxx@xxx.com"}],multi: true})
我如何使用“member.Email”:“xxx@xxx.com”更新元素以使其成为子[“xxx”,“Forne”]
但它打印:
name: 'MongoError',
message: 'No array filter found for identifier \'elem1\' in path \'member.$[elem1].sub\'',
driver: true,
index: 0,
code: 2,
errmsg: 'No array filter found for identifier \'elem1\' in path \'member.$[elem1].sub\'' }
如何更新“sub”:[]...?
最佳答案
db.getCollection('tests').update({
"group_token":"3bu48xp9ok5", "member.Email" : "xxx@xxx.com"
},
{
"$set": {"member.$.sub": ["hhh", "Cat"]}
})
文档之前:
{
"_id" : ObjectId("5bd2f41ed79cc5d8b1c62972"),
"group_id" : 1,
"group_token" : "3bu48xp9ok5",
"group_passward" : "0000",
"admin" : "Forne",
"member" : [
{
"mid" : 1,
"Name" : "Forne",
"Email" : "xxx@xxx.com",
"Rank" : "admin",
"sub" : [
"test",
"xxx",
"Forne"
]
},
{
"mid" : 1,
"Name" : "Forne",
"Email" : "yyy@yyy.com",
"Rank" : "admin",
"sub" : [
"test1",
"yyyy",
"Forte"
]
}
]
}
更新文档后:
{
"_id" : ObjectId("5bd2f41ed79cc5d8b1c62972"),
"group_id" : 1,
"group_token" : "3bu48xp9ok5",
"group_passward" : "0000",
"admin" : "Forne",
"member" : [
{
"mid" : 1,
"Name" : "Forne",
"Email" : "xxx@xxx.com",
"Rank" : "admin",
"sub" : [
"hhhh",
"hhhh",
"hhhh"
]
},
{
"mid" : 1,
"Name" : "Forne",
"Email" : "yyy@yyy.com",
"Rank" : "admin",
"sub" : [
"test1",
"yyyy",
"Forte"
]
}
]
}
关于node.js - 如何使用 arrayFilters 更新数组中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53004456/
我试图做一个匹配一些嵌套数组条件的 mongodb 查询,但没有成功...... 文件: [ { "_id":1, "name":"foo", "games"
我的查询是关于更新以数组形式存储的多个子文档。 环境:我的电脑上安装了MongoDB shell版本v3.6.3、python 3.6.9和pymongo 3.6.1。 架构示例: dept : {
我在 Mongodb 3.6 上运行,带有 mongo 驱动程序 3.4.3 和 spring data mongo 1.5.10。下面是我的文档结构 { "_id": 12345, "_cl
这里是 knockout 新手。我尝试使用 ko.utils.arrayFilter 但当我使用它时它似乎没有更新。我使用与 arrayForEach 相同的方法,所以我不确定这里出了什么问题。使用
我在 mongo 中存储了以下文件: { "_id" : ObjectId("5d1a08d2329a3c1374f176df"), "associateID" : "1234567", "assoc
我试图通过忽略已经在先前列表中的用户来过滤数组: FullList: Tom, Tim, Jim, Jill UsersList: Tom, Jill 在另一位成员的帮助下,我能够使用这个数组过滤器,
假设文档如下: { "group_id": 1, "group_token": "3bu48xp9ok5", "group_passward": "0000", "admin": "F
我见过像 this 这样的例子或this SO question我们可以轻松地使用位置 $ 运算符来更新数组中的对象。 我正在尝试做同样的事情,但我必须使用对象子属性。 示例: // Data mod
将查询转换为 Node 。 arrayfilter 在哪个版本的 mongoose 中工作或者如何在 Node 应用程序中运行这些 db.getCollection('student').update
我正在尝试使用 arrayFilters 更新嵌套数组,根据文档,它似乎应该可以工作,但我遇到了错误: Error parsing array filter: Expected a single to
大家好,我正在尝试向一个项目添加一个过滤系统,该系统允许用户根据他们在输入字段中键入的内容来过滤一组位置,所发生的情况是它会自动填充 5 组对象,而且用户输入的内容并没有真正执行任何操作,并且我从网站
我使用 $[] 的更新失败。架构: tables: { type: [ { tableID: String, numberOfC
在批量操作中使用 arrayFilters 执行 NodeJS/MongoDB updateOne 的正确语法是什么? MongoDB 版本:4.2.5 NodeJS 版本:12.x npm mong
所以我最近使用 knockout.js 将我想要的过滤系统插入到我的项目中。我将以下代码插入到我的项目中。 self.pointsFilter = ko.computed(function(){
我必须过滤评论中仅包含状态 C 的对象(如果至少只有评论具有状态 C,则应单独打印该对象)我尝试使用数组过滤器,但我没有得到准确的结果 { "_id" : ObjectId("5b8
我有一个看起来像这样的 observableArray: this.menuItems = ko.observableArray([ { name: "level1", subItems: [
就目前而言,我能够使用 Mongo shell 实现此功能,但在使用 Mongoose 的 Node.js 内部嵌套数组时遇到问题。 成功的Mongo shell命令: db.test.update(
这个问题在这里已经有了答案: How to Update Multiple Array Elements in mongodb (15 个回答) 3年前关闭。 我问过 question几天前关于更新嵌
大家好,我正在尝试创建一个应用程序,在进行 knockout 搜索时将适当的标记设置为可见。 应用程序基本上是。当有人搜索它下面的列表时,过滤列表并仅使与过滤列表相关联的标记在 map 上可见。我已经
我正在使用 Spring boot 2.2.1.RELEASE。如何使用 Spring MongoOperation 编写以下 MongoDB 更新查询 db.cities.updateOne(
我是一名优秀的程序员,十分优秀!