new DynamicSchema()
(DEPRECATED - Use createSchemaInstance()
instead)
Create an new DynamicSchema instance
(DEPRECATED - Use createSchemaInstance()
instead)
Create an new DynamicSchema instance
The name of the table.
The slug of the table.
The table's column definitions.
Label of required fields of this schema. Array of strings.
Description of the schema. Not used for anything internally.
The underlying JSON Schema definition of the schema
Create a new table with the given schema. Schema must adhere to the JSON Schema definition set out in https://json-schema.org/
Each property corresponds to each column in the database. A few custom attributes to each property can be included for use by DynamicSchema to generate columns for special behaviour.
These properties are:
isIndex
: Whether the column is an index fieldisUnique
: Whether the column is an unique fieldisAutoIncrement
: Whether the column is an auto-incrementing integerschema
: object
schema.$id
: string - ID of the table, must be unique
schema.title
: string - Defaults to `schema.$id`
schema.properties
: object - The column definitions of the table
Drop the table from the database.
Rename the table.
newSlug
: string
newName
: string - Defaults to newSlug
Add an index to the table's schema.
options
: object
options.name
: string - The name of the column to be used as index
options.unique
: boolean - Whether the index is unique or not
options.autoInrement
: boolean - Whether it is an auto-incrementing index or not. If true, `options.unique`
is automatically set to true
Remove an index to the table's schema
columnName
: string - The name of the index to remove
Read the schema definition from the database.
tableSlug
: string - The name of the table schema to retrieve
Define the table's columns. Passed object must adhere to properties
attribute of JSON Schema's definition.
Optional required
parameters define any of the columns as a required field.
Note that this function replaces any existing definition on the table. If you want to edit individual columns, you should use other functions instead.
definition
: object - Definition of the table columns
required
: Array - Array of column names that are required fields
Add a single column to the table's schema definition. If the column name is already in use, this will return a rejected Promise.
name
: string - The name of the column to add
type
: string - Type of the column to add
description
: string - Description of the column to add
Add multiple columns to the table's schema definition. If any of the given columns already exist, this will return a rejected Promise. None of the changes will be made.
definitions
: object - Object of objects containing new columns definitions
Rename a single column in the table's schema definition.
name
: string - The name of the column to rename
newName
: string - The new name of the target column
Change the type of a single column in the table's schema definition.
name
: string - The name of the column to change type
newType
: string - The new type of the target column
Remove a single column from the table's schema definition.
name
: string - The name of the column to remove