insertOrUpdate example is needed

441 views
Skip to first unread message

Ofer Shapira

unread,
Feb 14, 2016, 11:39:50 AM2/14/16
to Sequelize
I cant understand how to use findOne and then update the attributes of returning instance
web has variety of answers: using findOne.then, using findOne.success,  using update() on return, or updateAttribute
someone also wrote that update has to include "where" inside of it
so i am a bit confused, what is the right way to do it
Also, i've tried to use Upsert but received an error: Unhandled rejection TypeError: user.upsert is not a functionI'd like to use "insert or update" but can't find a good example on Sequelize documentations
Can anyone please kindly assist?

Mick Hansen

unread,
Feb 14, 2016, 2:20:54 PM2/14/16
to Ofer Shapira, Sequelize
upsert is a method on the model
all methods in sequelize return promises, it would help to show what you actually have at the moment
--
Mick Hansen
@mhansendev
mhansen.io
Reply all
Reply to author
Forward
0 new messages