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

时间:2017-06-02 05:30:23

标签: mongodb meteor

我在这个结构中有一个文件

{
  _id: 'playlistId',
  list_of_songs: [
    {
      _id: 'songId',
      song_title: 'Hello World',
      song_artists: [
        {
          artist_name: 'Aaron',
        }, {
          artist_name: 'Ben',
        }
      ]
    }
  ]
}

我打算替换整个数组list_of_songs.$.song_artists以获取“Hello World'在更新操作中

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

Playlist.update({  _id: 'playlistId', }, {
  $set: {
    'list_of_songs.0.song_artists': newArrayOfArtists
  }
}

但是我遇到了这个错误

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

我做错了什么,或者这是由于MongoDB的限制(见Updating nested arrays in mongoDB via mongo shell)?我在这里完全失败,非常感谢你的帮助。

0 个答案:

没有答案
相关问题