Class: Ottoman

Ottoman


new Ottoman()

The core manager class for the ODM.

Methods


_applyPlugins(a)

Applies global plugins to models as they are created.

Parameters:
Name Type Description
a model

new model that has been created.

Returns:

the ottoman singleton for chaining.


ensureIndices(callback)

Ensures all currently registered indices have been persisted to the data store and are useable.

Parameters:
Name Type Description
callback function

fromCoo(data, type)

Decodes a model instance from a data object.

Parameters:
Name Type Description
data Object
type string
Returns:
Type
ModelInstance

getModel(name, prefixed)

Returns a specific model based on the name.

Parameters:
Name Type Description
name string
prefixed boolean
Returns:
Type
ModelInstanceCtor

isModel(model)

Returns whether the passed type is a model instance.

Parameters:
Name Type Description
model *
Returns:
Type
boolean

isTypeDef(type)

Returns whether the passed type is a typedef object.

Parameters:
Name Type Description
type *
Returns:
Type
boolean

model(name, schemaDef, options)

Creates and registers a model object.

Parameters:
Name Type Description
name string
schemaDef Object
options Object
Properties
Name Type Default Description
index Object
queries Object
id string "_id"
store StoreAdapter this.store
Returns:
Type
ModelInstanceCtor

nsPrefix()

Returns the currently specific namespace prefix for this manager.

Returns:
Type
string

plugin(pluginFn, options)

Registers a global plugin with ottoman. Global plugins will be attached to all models defined after this call.

Parameters:
Name Type Description
pluginFn

the plugin, which must be a function.

options

an options object to pass to the plugin function when it is called.

Returns:

the ottoman singleton for chaining.


toCoo(obj)

Encodes a model instance to its JSON representation.

Parameters:
Name Type Description
obj ModelInstance
Returns:
Type
Object

type(name, options)

Creates a typedef specifying a simple name for a list of field options.

Parameters:
Name Type Description
name string
options Object
Returns:
Type
TypeDef

typeByName(type)

Returns the type data for a specific type by name. This can be a model, a typedef or a core type.

Parameters:
Name Type Description
type string
Returns:
Type
ModelInstance | TypeDef | CoreType

validate(mdlInst)

Executes the validation logic against a model and throws exceptions for any failures.

Parameters:
Name Type Description
mdlInst ModelInstance