Module bauplan.collection

Generic collection

var BauplanCollection = require("bauplan.collection");

or as part of the Bauplan bundle

var Bauplan = require("bauplan");
var BauplanCollection = Bauplan.Collection;

Create and instantiate a new collection class

var FooCollection = Bauplan.Collection.extend({});
var foocollectioninstance = new FooCollection();

Create a collection that requires authentication

var AuthenticatedFooCollection = Bauplan.Collection.extend({
    _collection: "authfoo",
    authenticated: true
});

Set a collection’s endpoint URL

var RestFooCollection = Bauplan.Collection.extend({
    _collection: "restfoo",
    url: "/foos"
});

Set a collection’s model

var FooModel = require("foo.model");
var ModelFooCollection = Bauplan.Collection.extend({
    _collection: "restfoo",
    model: FooModel
});
Listens to Events
Returns

BauplanCollection

Type
constructor

Extends

  • Thorax.Collection

Requires

  • thorax
Source:

Methods

(static) extend(optionsopt) → {constructor}

Parameters
Name Type Attributes Description
options object <optional>

Constructor options

Properties
Name Type Attributes Default Description
_collection string <optional>

Model name

model model <optional>

Collection model

authenticated boolean <optional>
false

Whether this collection requires authentication NB. not necessary to set this if the collection model is protected

url string | function <optional>

URL for collection endpoint…

urlRoot string <optional>

… or URL stub for use with instance _id

Source:
Returns

Collection

Type
constructor

(static) fetch()

Overrides Thorax.Collection.prototype.fetch

Prevented from being called if:

  • authentication is required
Source:

(inner) initialize(modelsopt, optionsopt)

Passes values and options to the constructor when creating a new instance

Creates attribute whitelist on first initialization and fetches unstance values if necesary

Parameters
Name Type Attributes Description
models array <optional>

Initial models to instantiate collection with

options object <optional>

Additional options

options.​selector string <optional>

Selector key

options.​selectorType string <optional>

SelectorType key

options.​fromID string <optional>

fromID key

options.​fromType string <optional>

fromType key

options.​hasID string <optional>

hasID key

options.​hasType string <optional>

hasType key

Source: