30 lines
789 B
JavaScript
30 lines
789 B
JavaScript
|
var cdb = require('cartodb.js-v3');
|
||
|
|
||
|
/**
|
||
|
* Model representing the query string params for a "paged search" of a collection (matching the server-side APIs).
|
||
|
*
|
||
|
* @example usage
|
||
|
* var PagedSearch = require('common/paged_search_model');
|
||
|
* pagedSearch = new PagedSearch({ … })
|
||
|
* pagedSearch.fetch(collection) // => jqXHR, GET /collection/123?page=1&per_page20
|
||
|
* pagedSearch.set({ page: 2, per_page: 10, q: 'test' });
|
||
|
* pagedSearch.fetch(collection) // => GET /collection/123?page=2&per_page10&q=test
|
||
|
*/
|
||
|
module.exports = cdb.core.Model.extend({
|
||
|
|
||
|
defaults: {
|
||
|
per_page: 20,
|
||
|
page: 1
|
||
|
// order: 'name'
|
||
|
// q: '',
|
||
|
},
|
||
|
|
||
|
fetch: function(collection) {
|
||
|
collection.trigger('fetching');
|
||
|
return collection.fetch({
|
||
|
data: this.attributes
|
||
|
});
|
||
|
}
|
||
|
|
||
|
});
|