Class: Ottoman

Ottoman

new Ottoman()

The core manager class for the ODM.

Methods

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) → {ModelInstance}

Decodes a model instance from a data object.

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

getModel(name, prefixed) → {ModelInstanceCtor}

Returns a specific model based on the name.

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

isModel(model) → {boolean}

Returns whether the passed type is a model instance.

Parameters:
Name Type Description
model *
Returns:
Type
boolean

isTypeDef(type) → {boolean}

Returns whether the passed type is a typedef object.

Parameters:
Name Type Description
type *
Returns:
Type
boolean

model(name, schemaDef, options) → {ModelInstanceCtor}

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() → {string}

Returns the currently specific namespace prefix for this manager.

Returns:
Type
string

toCoo(obj) → {Object}

Encodes a model instance to its JSON representation.

Parameters:
Name Type Description
obj ModelInstance
Returns:
Type
Object

type(name, options) → {TypeDef}

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) → {ModelInstance|TypeDef|CoreType}

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