Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.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
Mongodb 替换Mongo中的嵌套数组(使用Meteor)_Mongodb_Meteor - Fatal编程技术网

Mongodb 替换Mongo中的嵌套数组(使用Meteor)

Mongodb 替换Mongo中的嵌套数组(使用Meteor),mongodb,meteor,Mongodb,Meteor,我有一份这种结构的文件 { _id: 'playlistId', list_of_songs: [ { _id: 'songId', song_title: 'Hello World', song_artists: [ { artist_name: 'Aaron', }, { artist_name: 'Ben', } ] } ] }

我有一份这种结构的文件

{
  _id: 'playlistId',
  list_of_songs: [
    {
      _id: 'songId',
      song_title: 'Hello World',
      song_artists: [
        {
          artist_name: 'Aaron',
        }, {
          artist_name: 'Ben',
        }
      ]
    }
  ]
}
我打算在更新操作中替换“Hello World”的整个数组
歌曲列表。$.song\u艺术家

newArrayOfArtists = [{...}, {...}, {...}]

Playlist.update({  _id: 'playlistId', }, {
  $set: {
    'list_of_songs.0.song_artists': newArrayOfArtists
  }
}
但我犯了这个错误

cannot use the part (...) to traverse the element (...)

我是做错了什么,还是因为MongoDB的限制(请参阅)?我完全不知所措,非常感谢您的帮助。

您错过了报价<代码>“”它们是必需的<代码>“歌曲列表。0.歌曲艺术家”:newArrayOfArtists。另请参见核心文档。@NeilLunn抱歉,我这边的打字错误。引用不是问题。这可能是特定于minimongo的。这是在浏览器端还是服务器端运行?如果是浏览器,我认为这是一个问题。@NeilLunn它在服务器端和客户端遇到了相同的问题。
.update({“\u id”:“playlyid”},{“$set”:{“歌曲列表.0.歌曲艺术家”:[]})
对我来说很好。我只是把你的文件放在一个集合里,然后运行那个声明。我建议你在什么地方打错字。但具体的错误确实表明您错过了引用。