save
Save or update client data to the persisted data source.
instance.save(success, error)
Calls save.
// 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();
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.