Constructor
new Database(database)
Initialize the database from a schema object.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
database |
Object | A schema object representing the database. Any
custom properties on the database shall be preserved.
Properties
|
- Source:
Members
relStore :RelationshipStore
A RelationshipStore instances that exposes search methods for foreign key relationships.
Type:
- Source:
tables :Array.<Table>
An array of Table instances.
Type:
- Array.<Table>
- Source:
Methods
addTable(table) → {this}
Add a Table to the database.
Parameters:
Name | Type | Description |
---|---|---|
table |
Table | object | The new table, which must have a unique name and mapping (mapTo property). |
- Source:
Returns:
- Type
- this
getTableByMapping(mapping) → {Table}
Get a table by mapping.
Parameters:
Name | Type | Description |
---|---|---|
mapping |
string | The table mapping (mapTo property). |
- Source:
Returns:
The Table instance.
- Type
- Table
getTableByName(name) → {Table}
Get a table by name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the table. |
- Source:
Returns:
The Table instance.
- Type
- Table
isTableMapping(mapping) → {boolean}
Check if name is a valid table mapping.
Parameters:
Name | Type | Description |
---|---|---|
mapping |
string | The table mapping (mapTo property). |
- Source:
Returns:
A flag indicating if mapping corresponds to a Table
instance.
- Type
- boolean
isTableName(name) → {boolean}
Check if name is a valid table name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the table. |
- Source:
Returns:
A flag indicating if name corresponds to a Table
instance.
- Type
- boolean