Class SingleManager

Proxy for a single model instance, that should be loaded lazily. Used for ForeignKeys. The actual instance is loaded when get() is called.

class SingleManager(modelDef, id)
Arguments:
  • modelDef (Object) – Model definition of the base model. See Model.
  • id – The value of the primary key of the instance this object represents.

Methods

get

Fetches the instance from the database and calls callback with it as argument.

SingleManager.prototype.get(callback)
Arguments:
  • callback (Function) – A callback function that is called when the instance that this proxy represents was fetched from the database.

Passes the instance as parameter to the callback.

set

Sets the instance

SingleManager.prototype.set(instance)
Arguments:
  • instance (Model) – The instance this proxy reprents