save
Save the instance's data to the service via the connection.
instance.save(success, error)
Calls save.
Parameters
- success
{function}
:A function that is called if the save is successful.
- error
{function}
:A function that is called if the save is rejected.
Returns
{Promise<Instance>}
:
A promise that resolves to the instance if successful.
Usage
// import connection plugins
var canMap = require("can-connect/can/map/map");
var constructor = require("can-connect/constructor/constructor");
var dataUrl = require("can-connect/data/url/url");
// define connection types
var Todo = DefineMap.extend({
id: "number",
complete: "boolean",
name: "string"
});
// create connection
connect([canMap, constructor, dataUrl], {
Map: Todo,
url: "/todos"
})
new Todo({name: "dishes"}).save();