-
Notifications
You must be signed in to change notification settings - Fork 18
Doesn't work with graph inserts? #16
Copy link
Copy link
Open
Labels
Description
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?
Reactions are currently unavailable