Skip to content

Constants

Branden Horiuchi edited this page Jul 6, 2015 · 2 revisions

Constants


knex-schemer includes a constants module that can be used when defining schema types and options


Example
var schemer = require('knex-schemer')(knex);
var c       = schemer.constants;
console.log(c.string);

// > string

Constants Object
{
  type: {
    integer: 'integer',
    bigInteger: 'bigInteger',
    string: 'string',
    text: 'text',
    float: 'float',
    decimal: 'decimal',
    boolean: 'boolean',
    date: 'date',
    dateTime: 'dateTime',
    time: 'time',
    timestamp: 'timestamp',
    binary: 'binary',
    json: 'json',
    uuid: 'uuid'
  },
  options: {
    type: 'type',
    size: 'size',
    textType: 'textType',
    precision: 'precision',
    scale: 'scale',
    increments: 'increments',
    standard: 'standard',
    length: 'length',
    jsonb: 'jsonb',
    index: 'index',
    indexName: 'indexName',
    indexType: 'indexType',
    primary: 'primary',
    unique: 'unique',
    references: 'references',
    inTable: 'inTable',
    onDelete: 'onDelete',
    onUpdate: 'onUpdate',
    defaultTo: 'defaultTo',
    unassigned: 'unassigned',
    nullable: 'nullable',
    first: 'first',
    after: 'after',
    comment: 'comment',
    ignore: 'ignore'
  },
  relations: {
    hasOne: 'hasOne',
    hasMany: 'hasMany',
    belongsTo: 'belongsTo',
    belongsToMany: 'belongsToMany'
  },
  extend: {
    extendProto: 'extendProto',
    extendClass: 'extendClass'
  }
}