Skip to content

Commit

Permalink
Fixed song schema issue
Browse files Browse the repository at this point in the history
  • Loading branch information
patw0929 committed Dec 19, 2018
1 parent 788a2e5 commit 36839a4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/models/song.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const SongSchema = new Schema({
type: Schema.Types.ObjectId,
ref: 'lyric'
}]
}, {
usePushEach: true,
});

SongSchema.statics.addLyric = function(id, content) {
Expand All @@ -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);
});
Expand Down

0 comments on commit 36839a4

Please sign in to comment.