Service APIs  page     

Models provide an abstract API for connecting to your Services.
By implementing static:

You can find more details on how to implement each method. Typically, you can just use templated service urls. But if you need to implement these methods yourself, the following is a useful quick reference:

create(attrs, success([attrs]), error()) -> deferred

  • attrs - an Object of attribute / value pairs
  • success([attrs]) - Create calls success when the request has completed successfully. Success can be called back with an object that represents additional properties that will be set on the instance. For example, the server might send back an updatedAt date.
  • error - Create should callback error if an error happens during the request
  • deferred - A deferred that gets resolved to any additional attrs that might need to be set on the model instance.

findAll( params, success(items), error) -> deferred

  • params - an Object that filters the items returned
  • success(items) - success should be called with an Array of Model instances.
  • error - called if an error happens during the request
  • deferred - A deferred that gets resolved to the list of items

findOne(params, success(items), error) -> deferred

  • params - an Object that filters the item returned
  • success(item) - success should be called with a model instance.
  • error - called if an error happens during the request
  • deferred - A deferred that gets resolved to a model instance

update(id, attrs, success([attrs]), error()) -> deferred

  • id - the id of the instance you are updating
  • attrs - an Object of attribute / value pairs
  • success([attrs]) - Call success when the request has completed successfully. Success can be called back with an object that represents additional properties that will be set on the instance. For example, the server might send back an updatedAt date.
  • error - Callback error if an error happens during the request
  • deferred - A deferred that gets resolved to any additional attrs that might need to be set on the model instance.

destroy(id, success([attrs]), error()) -> deferred

  • id - the id of the instance you are destroying
  • success([attrs]) - Calls success when the request has completed successfully. Success can be called back with an object that represents additional properties that will be set on the instance.
  • error - Create should callback error if an error happens during the request
  • deferred - A deferred that gets resolved to any additional attrs that might need to be set on the model instance.
© Jupiter IT - JavaScriptMVC Training and Support