From 36839a40d239eefd6138586345df46d6ca6aba6d Mon Sep 17 00:00:00 2001 From: patw Date: Wed, 19 Dec 2018 11:15:01 +0800 Subject: [PATCH] Fixed song schema issue https://github.com/StephenGrider/Lyrical-GraphQL/issues/17 --- server/models/song.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); });