getList
Retrieve a list of instance.
Map.getList(query)
.getList
is added to the configured Map type. Retrieves a List of
Map instances via the connection.
// 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({filter: {due: "today"}}).then(function(todos){
...
});
Parameters
- query
{Query}
:Definition of the list being retrieved.