Data Types - Hookyns/unimapperjs GitHub Wiki
Object returned by require("unimapperjs")
contains property type
. This property contains getters for:
- string
- number
- boolean
- date
- uuid
- foreign
This getters return new instances of Type and allow you to change behavior with method chaining.
- length(number)
- default(valueOrFunctionReturningValue)
- nullable() - allow inserting nulls
- unique() - tell that value must be unique
- primary() - add primary key
- length(number) - length of number when in string (not stored as string for sure) it tells how big numbers you want to store
- decimals(numberOfDecimals)
- autoIncrement() - enable automatic incerementing for integers (no decimals set)
- default(valueOrFunctionReturningValue)
- nullable() - allow inserting nulls
- unique() - tell that value must be unique
- primary() - add primary key
- default(valueOrFunctionReturningValue)
- nullable() - allow inserting nulls
- length(number)
- default(valueOrFunctionReturningValue)
- now() - equals to default(() => new Date())
- nullable() - allow inserting nulls
- unique() - tell that value must be unique
- primary() - add primary key
Uuid by RFC4122
- unique() - tell that value must be unique
- notPrimary() - in default Uuid is marked as primary
-
constructor(entityName: string) - you must declare foreign as
foo = type.foreign("Foo")
- withForeign(field: ((map: TEntity) => any) | string) - creating *:1 relation, marking (number, uuid) field inside entity where this foreign type is
- hasMany(foreignField: ((map: TEntity) => any) | string) - creating *:N relation, marking (number, uuid) field in related entity which points to this entity