Class: BookshelfMapping

BookshelfMapping

Describes a DB Mapping


new BookshelfMapping()

Properties:
Name Type Argument Default Description
tableName string

Fully qualified name of DB Table

identifiedBy string <optional>
"id"

Primary key column

columns Array.<(String|ColumnDescriptor)> <optional>

columns to fetch. 'underscore_space' will be converted to 'lowerCamelCase' in Entity

discriminator Object | function <optional>

Fetch only Entities which match a given query, Knex where condition

onDelete Object <optional>

Execute instead of regular delete statement, Knex update statement

keepHistory Boolean <optional>
false

Keep an History History in this table. New states are appended instead of updated.
Columns 'revision_id' and 'parent_id' will be added to mapping, thus requires these columns in DB.
'revision_id' must have a unique default value, is the Primary Key at best.
'identifiedBy' must not be the Primary Key, since many revisions with the same ID can exist.

historyColumns Boolean <optional>
{ revisionId: "revision_id", parentId: "parent_id" }

Configure alias for history columns

relations Array.<RelationDescriptor> <optional>

Managed relations of this Entity.
There will be a getter and setter for n:1 relations
There will be a getter and modifiers ("add"/"remove" + relation.name) for m:n relations

Source: