Skip to content

Column Options

Branden Horiuchi edited this page Nov 23, 2015 · 7 revisions

❁ Description


Column Options provide additional configuration or extension data for the column they are added to. Currently Knex.js and Bookshelf.js relation options come standard along with built-in knex-schemer options. Since options are part of an extensible object, custom options can be added as needed as long as the names do not conflict with the options defined here. Some options also have additional modifier options that can be specified as separate (parameter:value) pairs.

❁ knex-schemer Options


Specific to knex-schemer

Option Overview
ignore : Boolean Prevents the Column from being created
compositeUnique : String | String[] Creates a composite unique constraint between the current column and one or more others in the table

❁ Knex.js Options


Must accompany a Column with a defined Data Type

Option Modifier Option(s)
after : String field name  
comment : String  
defaultTo : String | Number  
first : Boolean  
index : Boolean indexName : String
indexType: String Postgres Only
inTable : String table name  
nullable : Boolean  
onDelete : String command  
onUpdate : String command  
primary : Boolean  
references : column  
unique : String  

❁ Bookshelf.js Options


These options do not require a Data Type and will cause the Column to be ignored during the schema creation

Option Modifier Option(s)
belongsTo : String model name connectRelation: String relation name
belongsToMany : String model name connectRelation: String relation name
hasMany : String model name connectRelation: String relation name
hasOne : String model name connectRelation: String relation name
extendClass : Object  
extendProto : Object  
virtuals : Object  

❁ Examples