ember-data-slug

0.0.2 • Public • Published

ember-data-slug Build Status

Slug support for store.findRecord.

If your API supports to reference a model via slug additionally to the id, then this addon allows you to use findRecord with both the slug or id:

// GET /videos/best-dance-ever
let findViaSlug = store.findRecord("video", "best-dance-ever");

// GET /videos/1
let findViaId = store.findRecord("video", "1");

// both requests return the same response
// {
//   id: "1",
//   slug: "best-dancing-ever",
//   url: "https://www.youtube.com/watch?v=1TphEh0Qgv0"
// }

This addon ensures that the same records are referenced within Ember Data:

Ember.RSVP.all([ findViaSlug, findViaId ]).then(function([ foundViaSlug, foundViaId ]) {
  // true
  foundViaSlug === foundViaId;
});

Install via:

ember install ember-data-slug

Development

Installation

  • git clone this repository
  • npm install
  • bower install

Running

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.

Readme

Keywords

Package Sidebar

Install

npm i ember-data-slug

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • pangratz