DbSchema - do-/node-doix-db GitHub Wiki
DbSchema
is a named DbObject collection representing a single schema of a database.
Besides being a container, DbSchema
acts as the objects factory: each DbObject instance should appear as a result of its create method, normally, in the course of add'ing it to the registry, e. g. when loading it from source files.
Properties
Name | Type | Description |
---|---|---|
model |
DbModel | The model this schema belongs to. |
name |
String |
logical name of this schema in the containing DbModel. null for the default schema. |
schemaName |
String |
physical name of this database schema, unquoted. Must be unique inside a given model |
prefix |
String |
quoted schemaName with . appended after, or an empty string if it's undefined |
map |
Map | Collection of DbObjects of the schema described |
src |
DbSchemaSource | Where to find source files to load |
Events
Name | Description | Note |
---|---|---|
'object-created' |
Emitted for each object create d in the context of this schema |
But not necessarily made its part |
'object-added' |
Emitted for each object actually add ed to the model |
Methods
add
Parameters
Name | Type | Description |
---|---|---|
name |
String |
The name of the DbObject instance to create |
options |
Object |
The bag of options to pass to the constructor |
Description
This synchronous method:
- sets
options.name
toname
; - creates a new DbObject instance of with
create (options)
; - stores the object into
this.map
usingname
as the key. - emits the
'object-added'
event with the instance as the payload;
create
This synchronous method:
- takes the bag of
options.name
; - calls
lang.getDbObjectClass (options)
; - creates a new instance of the resulting class with
options
passed as a parameter; - injects
schema
,model
andlang
fields therein; - calls setLang for the object created (which triggers vendor dependent adjustments);
- emits the
'object-created'
event with the instance as the payload; - returns the object created.