DS#createCollection

DS#createCollection(resourceName[, array][, params][, options])

Create a new collection of the specified Resource. Collection are somewhat like Backbone.Collection. They have a .fetch([options]) method which will call DS#findAll with the params you provided, and splice the result into the collection.

You can create Collections that use cacheResponse: false, so their contents are never injected into the store, otherwise Collections end up being a subset of the data in the store.

πŸ‘

You can call DS#createCollection multiple ways

  • DS#createCollection(resourceName[, array][, params][, options])
  • Resource#createCollection([array][, params][, options]) - Where Resource was created by DS#defineResource
ArgumentTypeDescription
resourceNamestringThe name of the resource to use. Unnecessary if calling createCollection directly on a Resource.
array (optional)arrayDefault [ ].
params (optional)objectQuery parameters. Default: {}. See Query Syntax.
options (optional)objectSettings are inherited from Resource and Global defaults. Will be passed through to DS#findAll, the adapter's findAll method and DS#inject, if they are called.

Demo

πŸ“˜

Need help!

Want more examples or have a question? Ask on the Slack channel or post on the mailing list then we'll get your question answered and probably update this wiki.