var Backbone = require('backbone'),
    Item = require('./item'),
    Globals = require('../globals');

var ItemSearchCollection = Backbone.Collection.extend({
    initialize: function() {
        $.ajaxPrefilter(
            function(options, originalOptions, jqXHR) {
                options.xhrFields = {
                    withCredentials: true
                }
            }
        );
    },
    setQuery: function(q) {
        this.q = q;
    },
    model: Item,
    url: function() {
        return Globals.ApiUrl + "/search?q=" + this.q;
    }
});

module.exports = ItemSearchCollection;
