seegno / objection-unique Goto Github PK
View Code? Open in Web Editor NEWUnique validation for Objection.js
Home Page: https://www.npmjs.com/package/objection-unique
Unique validation for Objection.js
Home Page: https://www.npmjs.com/package/objection-unique
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?
It seems that this plugin ensures that values from the fields specified are each unique on the table. How would I go about using this plugin to ensure that the values of my fields are unique together in the table, but each is not forced to be unique on its own? Thank you for your help, and thank you for the work you've put in on this plugin!
I have used "objection-soft-delete" package for soft delete data. I want to handle "objection-unique" with "objection-soft-delete". Currently, it's will also check deleted data.
What is the preferred lock file for the project?
Hi!
First of all, thank you for building this plugin for objection. Having a collection of good quality plugins such as this one for the most common problems will do a lot of good for the objection ecosystem.
Objection changed its best practices regarding the name of the extending class returned from the mixin function. The class should not have a name. The reason for this change is explained in this issue.
Please consider updating your plugin to follow the updated practices.
This npm package needs a TypeScript types declaration file so that developers who enjoy writing with TS can use it with this package and have a better development experience. Would you like me to write one?
I am trying to use this module with the 'import' syntax, but the compiler complains that the resulting model does not contain a query() method.
import uniqueFn from 'objection-unique'
const unique = uniqueFn({
fields: ['email']
})
export default class User extends unique(Model) {
What is the proper way to import it?
Hi,
for [email protected] this plugin needs an update, as it is not working. Are you still working on the plugin?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.