getList
Method added to the configured Map type. Retrieves a List of Map instances via the connection.
Map.getList(set)
Parameters
- set
{Set}
:set definition of the list being retrieved
Returns
{Promise<Map>}
:
Promise
returning the List of instances being retrieved
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"
});
Todo.List = DefineList.extend({
completed: function() {
return this.filter(function(item) { return item.completed; });
}
});
// create connection
connect([canMap, constructor, dataUrl],{
Map: Todo,
url: "/todos"
})
// retrieve instances
Todo.getList({due: "today"}).then(function(todos){
...
});