Skip to content

Methods

Branden Horiuchi edited this page Jul 6, 2015 · 1 revision

Methods


.sync( schema )
Creates tables based on the the defined schema if they do not exist. If a table does exist, the actual columns in the database will be added or dropped based on the schema definition

Currently the sync function creates tables that do not exist. If the table does exist it will first drop any columns that do not exist in the schema definition and add any that do not exist in the current table. In the future, the sync method will also update the column's type and attributes. Re-ordering columns is not currently on the road map since not all database platforms have a clean method.


**.syncTable(** *tableName*, *tableSchema* **)**
Creates or updates a single table. Returns a promise object
**.drop(** *schema* **)**
Drops all tables in the schema definition. Returns a promise object
**.dropTable(** *tableName* **)**
Drops a single table. Returns a promise object
**.load(** *data*, *schema* **)**
Inserts data into the database. Returns a promise object
**.convert(** *data*, *schema* **)**
Converts data to a format that is usable by the load function using the schema definition. Not necessary if data has been formatted correctly. Returns an object containing all of the data to load correctly formatted
**.convertAndLoad(** *data*, *schema* **)**
Combines the convert and load functions into a single call. Returns a promise object
**.util.getPrimaryKeys(** *tableSchema* **)**
Gets the primary keys for a table
**.util.checkSchema(** *data* , *tableSchema* **)**
Verifies that all required fields have been entered
Clone this wiki locally