The add lyrics query returns an error but saves in the database

I believe there's an issue either with the db model or the addLyrics mutation
yes. I'm also having the same issue.
Anyone with answers should please notify us here, so we can move forward with the course, this is a huge blocker
How far along are you in the video?
I'm currently in Client side graphql >> working through the schema
That should be the fourth video of the 6th section
So you cloned the repo, are you using monogodb atlas? https://www.mongodb.com/cloud/atlas
Finally, I got the solution. Thank you @PostIt59, by your solution only I could solve it.
I hope u can try this or you can check his solution in issue page at #17
In server/models/song.js just add:
usePushEach : true
onst SongSchema = new Schema({
title: { type: String },
user: {
type: Schema.Types.ObjectId,
ref: 'user'
},
lyrics: [{
type: Schema.Types.ObjectId,
ref: 'lyric'
}]
}, {
usePushEach : true
});
then change the addLyric as follows
song.lyrics.push(lyric) to song.lyrics.push(lyric.id)
SongSchema.statics.addLyric = function(id, content) {
const Lyric = mongoose.model('lyric');
return this.findById(id)
.then(song => {
const lyric = new Lyric({ content, song })
song.lyrics.push(lyric.id)
return Promise.all([lyric.save(), song.save()])
.then(([lyric, song]) => song);
});
}
Yes @levelingup , I'm using mongoDB Atlas, thanks @vishalisakar for the update, I'll try it now
Thanks guys, it worked. Now I can move on with the course, I think I should leave this here for people who would run into this problem so they can find the solution here