Skip to content

Doesn't work with graph inserts? #16

@tsongas

Description

@tsongas

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions