Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 更新MongoDB中数组中嵌套对象数组中嵌套对象数组中的值_Node.js_Mongodb - Fatal编程技术网

Node.js 更新MongoDB中数组中嵌套对象数组中嵌套对象数组中的值

Node.js 更新MongoDB中数组中嵌套对象数组中嵌套对象数组中的值,node.js,mongodb,Node.js,Mongodb,如何以编程方式更新表1的标题 这是一种静态方式: { _id: ObjectId("5757646866e59fac8d1d8589"), updatedAt: ISODate("2016-06-09T02:49:09.792Z"), createdAt: ISODate("2016-06-08T00:18:48.147Z"), books: [ { name: "book1", id: "1", chapters: [

如何以编程方式更新表1的标题

这是一种静态方式:

{
  _id: ObjectId("5757646866e59fac8d1d8589"),
  updatedAt: ISODate("2016-06-09T02:49:09.792Z"),
  createdAt: ISODate("2016-06-08T00:18:48.147Z"),
  books: [
    {
      name: "book1",
      id: "1",
      chapters: [
        {
          id: "1",
          name: "CH1",
          details: "Chapter 1",
          tables: [
            {
              table : 1, 
              heading : 'heading 1' // update this
            },
            {
              table: 2,
              heading: 'heading 2'
            }
          ]
        }
      ]
    }
  ]
}
我想做的是这样的:

db.books.update({_id: ObjectId("5757646866e59fac8d1d8589")},
{$set: {"books.0.chapters.0.tables.0.heading": "new Heading"}})
db.books.update({u id:ObjectId(“5757646866e59fac8d1d8589”),
'books.id':'1',
'books.chapters.id':'1',
'书籍.章节.表格.表格':'1'},
{$set:{}})

可能
db.books.update({u id:ObjectId(“5757646866e59fac8d1d8589”),{$set:{“books.0.chapters.0.tables.0.heading:“newheading”}})
您应该澄清我们应该如何选择表1?这只是一个位置更新还是基于某些条件?只是更新了我认为的解决方案。
db.books.update({_id: ObjectId("5757646866e59fac8d1d8589"), 
  'books.id': '1',
  'books.chapters.id':'1', 
  'books.chapters.tables.table':'1' }, 
{$set: {<what>}})