-
Notifications
You must be signed in to change notification settings - Fork 1
Configuration
Radosław Mejer edited this page May 9, 2020
·
1 revision
const { Kex } = require('@baethon/kex')
const kex = new Kex({ /** options */ })
Supported options:
-
knex
(required when missingknexClientResolver
) instance of the Knex -
plugins
(optional;Array
) list of plugins -
knexClientResolver
(optional;Function
) custom resolver function for knex client -
modelDefaults
(optional;Object
) subset of model options, used when creating a new model; can be overwritten when usingcreateModel()
-
softDeletes
(Boolean|Object
) should the model use soft deletes? -
scopes
(Object
) model scopes -
globalScopes
(Object
) model global scopes -
timestamps
(Boolean
) should the model use timestamps?
-
const User = kex.createModel('User', { /** options */ })
When creating a new model, Kex will merge the modelDefaults
with passed options and use the results to set up the model.
Supported options:
-
tableName
(optional;String
) the name of the table; by default it's pluralized name of the model -
primaryKey
(optional;String
; default:id
) the name of the primary key -
softDeletes
(optional;Boolean|Object
; default:false
) should the model use soft-deletes? -
relations
(optional;Object
) list of model relations -
scopes
(optional;Object
) list of model scopes -
globalScopes
(optional;Object
) list of model global scopes -
timestamps
(optional;Boolean|Object
; default:false
) should the model use timestamps?
To enable soft-deletes you can pass a simple Boolean
value. The plugin accepts also an object with the following options:
-
columnName
(optional;String
; default:deleted_at
) the column used to mark record as deleted
To enable timestamps you can pass a simple Boolean
value. The plugin accepts also an object with the following options:
-
createdAtColumn
(optional;String
; default:created_at
) the column name used when creating new record -
updatedAtColumn
(optional;String
; deault:updated_at
) the column name used when updating new record