GithubHelp home page GithubHelp logo

leooo / ember-cli-has-many-through Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 2.0 21 KB

hasManyThrough property for Ember-Data models - deprecated for https://github.com/britishgas-engineering/ember-data-has-many-through

License: MIT License

JavaScript 91.64% HTML 8.36%

ember-cli-has-many-through's Introduction

Ember-cli-has-many-through

A small Addon to forward hasMany of hasMany relationships to the grand-parent.

Given an Ember-Data parent model with a hasMany children relationship on a child model that itself has a hasMany childrenOfChild relationship, then you can use the hasManyThrough computed property provided by this Addon to concatenate all the childrenOfChild of child models into a single childrenOfChild property on the parent model.

// models/parent.js
import DS from 'ember-data';
import hasManyThrough from 'dummy/macros/has-many-through';

export default DS.Model.extend({
  children: DS.hasMany('child'),
  // will concatenate the 'childrenOfChild' of each 'child' into a promiseArray CP
  childrenOfChild: hasManyThrough('children'),
  // if you want to name the property differently from the name given on the `children` hasMany property
  childrenOfChildren: hasManyThrough('children', 'childrenOfChild'),
  // this also works if the property on the 'child' model is an array (not a promise)
  childrenOfChildArray: hasManyThrough('children')
});
// models/child.js
import DS from 'ember-data';

export default DS.Model.extend({
  childrenOfChild: DS.hasMany('childOfChild'),
  childrenOfChildArray: []
});
// models/child-of-child.js
import DS from 'ember-data';

export default DS.Model.extend({});

See the test/dummy app for further examples.

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

ember-cli-has-many-through's People

Contributors

ember-tomster avatar leooo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kpandya3 awhicks

ember-cli-has-many-through's Issues

JS Lint Errors

I love this addon! Thanks a lot!

Don't know if you've ran the module through JSHint, but it gives me the following warnings:

modules/ember-cli-has-many-through/macros/has-many-through-non-object.js: line 35, col 13, Bad line breaking before '?'.
modules/ember-cli-has-many-through/macros/has-many-through-non-object.js: line 53, col 13, Bad line breaking before '&&'.
modules/ember-cli-has-many-through/macros/has-many-through.js: line 35, col 13, Bad line breaking before '?'.
modules/ember-cli-has-many-through/macros/has-many-through.js: line 53, col 13, Bad line breaking before '&&'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.