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

Doesn't work with graph inserts? #16

Open
tsongas opened this issue Mar 13, 2019 · 1 comment
Open

Doesn't work with graph inserts? #16

tsongas opened this issue Mar 13, 2019 · 1 comment
Labels

Comments

@tsongas
Copy link

tsongas commented Mar 13, 2019

I added objection-unique to my Users model to make user email addresses unique:

const unique = require('objection-unique')({
  fields: ['email'],
  identifiers: ['id']
});

However when I do a graph insert in my Account model as shown below to insert an account and related user, I get a database error due to the Postgres unique constraint, objection-unique doesn't seem to be doing anything:

  static createAccount(firstName, lastName, email, password, trialEnds) {
    return this.query().insertGraph({
      trialEnds,
      users: [
        {
          firstName,
          lastName,
          email,
          password
        }
      ]
    });
  }

Is this a known limitation of objection-unique that it doesn't work with graph inserts, or am I doing something wrong?

@joaonice
Copy link
Member

joaonice commented Apr 5, 2019

This is a known limitation. We're planning to resolve this issue but pull requests are welcome too.

Thank you for using objection-unique!

@joaonice joaonice added the bug label Apr 5, 2019
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