bulkCreate "INSERT OR IGNORE" capability

See original GitHub issue

Is it possible to use bulkCreate to insert multiple rows and ignore if the key is unique and exists? Currently when I update a table I get an error with the following:

{ [SequelizeUniqueConstraintError]
  name: 'SequelizeUniqueConstraintError',
  message: undefined,
  parent:
   { [Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: Files.path]
     errno: 19,
     code: 'SQLITE_CONSTRAINT',
     sql: 'INSERT INTO `Files` (`id`,`path`,`status`,`filename`,`filtered_filename`,`width`,`height`,`size`,`duration`,`createdAt`,`updatedAt`) VALUES ...

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
mickhansencommented, Nov 27, 2014

If you are using mysql (which it looks like you are), you pass ignoreDuplicates: true to the method to have it ignore duplicate/unique constraints.

0reactions
cirosantillicommented, Jun 18, 2021

Worth noting that it might not return generated IDs on the JavaScript objects currently: https://github.com/sequelize/sequelize/issues/11223

Read more comments on GitHub >

github_iconTop Results From Across the Web

sequelize Bulkcreate: Ignore if single row fails
I have to import rows from a .csv , and put them in my database (chunks of 500). To do this i'm using...
Read more >
MySQL INSERT IGNORE
Let us understand how INSERT IGNORE statement works in MySQL with the help of an example. First, we need to create a table...
Read more >
Use BULK INSERT or OPENROWSET(BULK...) to import ...
BULK INSERT loads data from a data file into a table. This functionality is similar to that provided by the in option of...
Read more >
Capabilities of InnoDB INSERT Performance
Hi I am running the most recent version of Percona Server. Server version: 5.5.24-55 Percona Server (GPL), Release 26.0. I have a 10...
Read more >
INSERT
INSERT INTO table-name ... This insert capability automatically compares unique keys for values to be inserted or ... CREATE TABLE t1 (c1 INT,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found