-
Notifications
You must be signed in to change notification settings - Fork 1
Knex Schemer Definition Format
Branden Horiuchi edited this page Sep 18, 2015
·
5 revisions
Knex-Schemer Definition Format or KSDF is a standard format for defining a relational database schema in JSON that can be extended to provide non-database specific data/configuration, and ultimately consumed by knex-schemer to create and manage a database schema via Knex.js .Related documentation: Data Types and Column Options |
||||||||
The following notations are used to document syntax where language is insufficient
|
||||||||
{ tableName: JSON Object of Table ...,} |
||||||||
{ columnName: JSON Object of Column ...,_extensionName: JSON Object (optional) ...,} |
||||||||
{ type: DataType (optional),option: ColumnOption (optional) ...,extension: Object (optional) ...,} |
||||||||
Creates Table(s)
user |
id | name | username | passwordHash | location | |
---|---|---|---|---|---|---|
type | INT(10) |
VARCHAR(255) |
VARCHAR(32) |
VARCHAR(255) |
VARCHAR(255) |
INT(10) |
options |
PrimaryKey ,NotNULL ,Unsigned ,AutoIncrement
|
NotNULL |
NotNULL ,Unique
|
NotNULL |
NotNULL |
location |
id | name |
---|---|---|
type | INT(10) |
VARCHAR(255) |
options |
PrimaryKey ,NotNULL ,Unsigned ,AutoIncrement
|
NotNULL |
Shows a table schema that has been extended to work with [`dreamcatcher.js`](https://github.com/bhoriuchi/dreamcatcher) which looks for a `_rest` field ```js var schema = { location: { id: { type: 'integer', primary: true, increments: true } name: { type: 'string' } }, _rest : { auth: function(req, res, next) { // authentication code }, methods: { HEAD: {} GET: {}, POST: {}, PUT: {}, DELETE: {} } } } ```
Creates Table(s)
location |
id | name |
---|---|---|
type | INT(10) |
VARCHAR(255) |
options |
PrimaryKey ,NotNULL ,Unsigned ,AutoIncrement
|
NotNULL |
knex-schemer