Pushing to arrays through upsert
Closed this issue · 1 comments
syffs commented
Hello,
I'm trying to find or upsert, but I have arrays in my Schema, and it apparently does not work to $push
as in here
User.findOrCreate({'social.facebook.id': profile.id},
{
social: {
facebook: {
id: profile.id,
first_name: profile.first_name,
last_name: profile.last_name,
access_token: {
expires_at: new Date().getTime() + json.expires_in,
token: accessToken
},
$push: {
friends: profile.friends.data
}
}
},
username: profile.email,
residence_location: profile.location,
gender: profile.gender,
email: profile.email,
birthday: profile.birthday,
$push: {
photos: {
value: profile.picture
}
}
}, {
upsert: true
}).then((user) => {
winston.debug('Facebook user ', user.username)
return done(null, user)
}).catch((err) => {
winston.debug('Facebook findOrCreate err: ', err)
return done(null)
})
Am I missing anything?
syffs commented
It must have been an issue with my environment, after cleaning the cache, it did work