node.js - Does Sequelize support Insert on duplicate key update? -


is there model or instance method perform insert or update, depending on whether or not record exists? preferably making use of mysql's "insert on duplicate key update" syntax?

they have added feature upsert or insertorupdate

  /**    * insert or update single row. update executed if row   * matches supplied values on either primary key or unique   * key found. note unique index must defined in sequelize   * model , not in table. otherwise may experience unique    * constraint violation, because sequelize fails identify row   * should updated.   */    model.upsert({uniquekey: 1234, name: 'joe'}).then(function () {         // cheer joy   }); 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -