Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate records being inserted #86

Closed
Kallaste opened this issue May 1, 2018 · 1 comment
Closed

Duplicate records being inserted #86

Kallaste opened this issue May 1, 2018 · 1 comment
Labels

Comments

@Kallaste
Copy link

Kallaste commented May 1, 2018

Hello,

I was under the impression from the docs that duplicates would not be inserted, however, I have a database with identical records being created on each program run. Calling very simply with:

if(app.get('env') === 'development'){
    sequelize_fixtures.loadFile('fixtures/*.json', db);
  }

I'm a C/Java programmer and I'm not very familiar with Node.js or JavaScript, so maybe I am missing something? Sorry if that is the case.

@matmar10
Copy link
Collaborator

Hi @Kallaste - you may need to specify a field to indentify the duplicates. Please see the docs under "Detect duplicates based on select fields". you need to specify the keys field:

On the first will be inserted in the following example:

{
    "model": "Person",
    "keys": ["email"],
    "data": {
        "name": "John",
        "email": "example@example.com"
    }
},
{
    "model": "Person",
    "keys": ["email"],
    "data": {
        "name": "Patrick",
        "email": "example@example.com"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants