diff --git a/server/models/song.js b/server/models/song.js index c4f372a..41d0779 100644 --- a/server/models/song.js +++ b/server/models/song.js @@ -11,6 +11,8 @@ const SongSchema = new Schema({ type: Schema.Types.ObjectId, ref: 'lyric' }] +}, { + usePushEach: true, }); SongSchema.statics.addLyric = function(id, content) { @@ -19,7 +21,7 @@ SongSchema.statics.addLyric = function(id, content) { return this.findById(id) .then(song => { const lyric = new Lyric({ content, song }) - song.lyrics.push(lyric) + song.lyrics.push(lyric.id) return Promise.all([lyric.save(), song.save()]) .then(([lyric, song]) => song); });