0
Ceci est mon modèle mangouste:Comment puis-je ajouter un document imbriqué à mongoose et non l'écraser?
...
images: new Schema({
poster: new Schema({
small: String,
medium: String,
big: String
}, { _id: false }),
backdrop: new Schema({
small: String,
medium: String,
big: String
}, { _id: false })
}, { _id: false }),
...
C'est ce que je fais:
Je reçois l'affiche, et mettre à jour images
comme ceci:
Movie.findOneAndUpdate({
id: {
imdb: movie.id.imdb
}
}, {
images: {
backdrop: {
small: backdrops.small,
medium: backdrops.medium,
big: backdrops.big
}
}
}
Il fonctionne bien. je reçois et je mets à jour Backdrops images
comme ceci:
Movie.findOneAndUpdate({
id: {
imdb: movie.id.imdb
}
}, {
images: {
backdrop: {
small: backdrops.small,
medium: backdrops.medium,
big: backdrops.big
}
}
}
problème est
Il remplace le document entier images
, ne pas ajouter backdrops
le long poster
. Comment puis-je y parvenir?