js-data

Respect Your Data

Give your data the treatment it deserves with a framework-agnostic, datastore-agnostic JavaScript ORM built for ease of use and peace of mind. Works in Node.js and in the Browser.

Get Started

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

Argument

Type

Description

resourceName

string

The name of the resource to use. Unnecessary if calling createCollection directly on a Resource.

array (optional)

array

Default [ ].

params (optional)

object

Query parameters. Default: {}. See Query Syntax.

options (optional)

object

Settings 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.

Updated less than a minute ago

DS#createCollection


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

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.