-
Notifications
You must be signed in to change notification settings - Fork 18
Plugin Writing Guide
A sync plugin is a Modella plugin that implements Model.save
, Model.update
,
and Model.remove
static methods which are invoked by model#save
and
model#remove
with this
bound to the model instance. See the
memory plugin for a bare bones
implementation.
A sync plugin must add the following methods to the Model class and implement the required callback signatures:
Model.save
is called with this
bound to the model instance. It must store
the instance's attributes and execute the callback with arguments error
and
attributes
.
This method saves the instance for the first time, so must include the newly
created id in attributes
.
Model.update
has the same signature as Model.save
but the instance already
has a primary id field, as it was previously saved.
Model.remove
is called with this
bound to the model instance. It must remove
the instance from storage and execute the callback with an optional error
argument.