Module: Schema

Schema factory.
Mixes In:
Source:

Methods

createCollection(name, optionsopt) → {Promise.<module:Collection>}

Create a new collection in the schema.
Parameters:
Name Type Attributes Description
name string collection name
options CreateCollectionOptions <optional>
setup options
Source:
Returns:
Type
Promise.<module:Collection>

dropCollection(name) → {Promise.<boolean>}

Drop a collection from the schema (without failing even if the collection does not exist).
Parameters:
Name Type Description
name string collection name
Source:
Returns:
Type
Promise.<boolean>

existsInDatabase() → {Promise.<boolean>}

Check if this schema exists in the database.
Source:
Returns:
Type
Promise.<boolean>

getClassName() → {string}

Retrieve the class name (to avoid duck typing).
Source:
Returns:
The "class" name.
Type
string

getCollection(name) → {module:Collection}

Retrieve the instance of a given collection.
Parameters:
Name Type Description
name string collection name
Source:
Returns:
Type
module:Collection

getCollectionAsTable(name) → {module:Table}

Retrieve the instance of a given table or named collection.
Parameters:
Name Type Description
name string collection name
Source:
Returns:
Type
module:Table

getCollections() → {Promise.<Array.<module:Collection>>}

Retrieve the list of collections that exist in the schema.
Source:
Returns:
A promise that resolves to the array of collection instances.
Type
Promise.<Array.<module:Collection>>

getName() → {string}

Retrieve the schema name.
Source:
Returns:
Type
string

getTable(name) → {module:Table}

Retrieve the instance of a given table.
Parameters:
Name Type Description
name string table name
Source:
Returns:
Type
module:Table

getTables() → {Promise.<Array.<module:Table>>}

Retrieve the list of tables that exist in the schema.
Source:
Returns:
A promise that resolves to the array of table instances.
Type
Promise.<Array.<module:Table>>

inspect() → {Object}

Retrieve the schema metadata.
Source:
Returns:
An object containing the relevant metadata.
Type
Object

Type Definitions

CreateCollectionOptions

Options available for creating a new collection.
Type:
  • object
Properties:
Name Type Attributes Description
ReuseExistingObject bool <optional>
re-use or throw error if a collection with the same name already exists
Source: