I have not used Sequelize, but after reading its documentation, it’s obvious that you are instantiating a new object, that’s why Sequelize inserts a new record into the db.
First you need to search for that record, fetch it and only after that change its properties and update it, for example:
Project.find({ where: { title: 'aProject' } }) .on('success', function (project) { // Check if record exists in db if (project) { project.update({ title: 'a very different title now' }) .success(function () {}) } })
Related Posts:
- Node.js MySQL – Error: connect ECONNREFUSED
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- How to use mysqli_query() in PHP?
- Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
- Start script missing error when running npm start
- Node.exe Stuck at 100% CPU
- Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
- ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
- Column count doesn’t match value count at row 1
- ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
- MySQL string replace
- Cannot add or update a child row: a foreign key constraint fails
- ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
- String concatenation in MySQL
- How do I debug error ECONNRESET in Node.js?
- How do I debug error ECONNRESET in Node.js?
- What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? [duplicate]
- Cannot add or update a child row: a foreign key constraint fails
- Client on Node.js: Uncaught ReferenceError: require is not defined
- Error: Can’t set headers after they are sent to the client
- MySQL Error “Operand should contain 1 column”
- How to use MySQL DECIMAL?
- Access denied for user ‘root@localhost’ (using password:NO)
- Client on Node.js: Uncaught ReferenceError: require is not defined
- Error: Can’t set headers after they are sent to the client
- TypeError: Router.use() requires middleware function but got a Object
- Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (38)
- Express error – TypeError: Router.use() requires middleware function but got a Object
- How to make MySQL table primary key auto increment with some prefix
- Access denied for user ‘root@localhost’ (using password:NO)
- MySQL ERROR 1290 (HY000) –secure-file-priv option
- What is Express.js?
- Cannot GET / Nodejs Error
- What is NODE_ENV and how to use it in Express?
- MySQL error 2006: mysql server has gone away
- Which MySQL data type to use for storing boolean values
- sql query with multiple where statements
- What does body-parser do with express?
- ERROR 2003 (HY000): Can’t connect to MySQL server on localhost (10061)
- node.js, Error: Cannot find module ‘express’
- ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
- Cannot delete or update a parent row: a foreign key constraint fails
- Cannot delete or update a parent row: a foreign key constraint fails
- ERROR 2003 (HY000): Can’t connect to MySQL server on localhost (10061)
- MySQL server startup error ‘The server quit without updating PID file’
- Rename a column in MySQL
- TypeError: Router.use() requires middleware function but got a Object
- node.js, Error: Cannot find module ‘express’
- nodemon – app crashed – waiting for file changes before starting
- “Topology was destroyed” when using MongoDB with native driver and Express.js
- What does “res.render” do, and what does the html file look like?
- “INSERT IGNORE” vs “INSERT … ON DUPLICATE KEY UPDATE”
- Cannot delete or update a parent row: a foreign key constraint fails
- Error: getaddrinfo ENOTFOUND in nodejs for get call
- MySQL server startup error ‘The server quit without updating PID file’
- How do I restore a dump file from mysqldump?
- Syntax error due to using a reserved word as a table or column name in MySQL
- ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
- MySQL root password change
- Installation of MySQL for Visual Studio 1.2.8 failed
- Not unique table/alias
- nodemon not working: -bash: nodemon: command not found
- How do I import an SQL file using the command line in MySQL?
- PHP Connection failed: SQLSTATE[HY000] [2002] Connection refused
- Failed to load resource: net::ERR_CONNECTION_REFUSED : Nodejs
- #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’
- MySQL ERROR 1045 (28000): Access denied for user ‘bill’@’localhost’ (using password: YES)
- Your password does not satisfy the current policy requirements
- How do I quickly rename a MySQL database (change schema name)?
- SyntaxError: Unexpected token import – Express
- What does SQL Select symbol || mean?
- Install mysql-python (Windows)
- MySQL: Access denied for user ‘test’@’localhost’ (using password: YES) except root user
- PHP Connection failed: SQLSTATE[HY000] [2002] Connection refused
- Error: No default engine was specified and no extension was provided
- SQL – Update multiple records in one query
- Significance of port 3000 in Express apps
- Mysql: Setup the format of DATETIME to ‘DD-MM-YYYY HH:MM:SS’ when creating a table
- What is the definition of cardinality in SQL
- ExpressJS – throw er Unhandled error event
- NodeJS / Express: what is “app.use”?
- How to restart remote MySQL server running on Ubuntu linux?
- Authentication plugin ‘caching_sha2_password’ cannot be loaded
- stop all instances of node.js server
- MySQL DROP all tables, ignoring foreign keys
- #1055 – Expression of SELECT list is not in GROUP BY clause and contains nonaggregated column this is incompatible with sql_mode=only_full_group_by
- When to use SELECT … FOR UPDATE?
- Why am I getting “Error socket hang up” response?
- Host ‘xxx.xx.xxx.xxx’ is not allowed to connect to this MySQL server
- Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
- Setting up foreign keys in phpMyAdmin?
- Select from multiple tables without a join?
- How to Create and Use Enum in Mongoose
- PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP
- ERROR 1396 (HY000): Operation CREATE USER failed for ‘jack’@’localhost’
- SQL Query Where Field DOES NOT Contain $x
- Create a new database with MySQL Workbench
- Duplicating a MySQL table, indices, and data
- Disable ONLY_FULL_GROUP_BY