CHECK constraints in Seqeulize PostgreSQL ORM (Node.js) -


i'm using sequelize orm postgresql engine. when using raw queries can create table , have columns 'check' constraints such

create table products (     product_no integer,     name text,     price numeric check (price > 0) ); 

in docs cannot find way in sequelize when defining models. there way of doing this? don't want reinvent wheel ;)

thanks!!

take @ validations section.

var product = sequelize.define('product', {   price: {     validate: {       min: 0  // allow values >= 0     }   } }); 

you can set custom validation rules:

var product = sequelize.define('product', {   price: {     validate: {       ispositive: function (value) {         return value > 0;  // don't allow 0.       }     }   } }); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -