npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ember-addon-ember-data-model-query

v0.1.2

Published

The default blueprint for ember-cli addons.

Readme

Ember-addon-ember-data-model-query

This addon provides a way to add query parameters when handling has-many relationships and depaginate them.

Compatibility

  • Ember.js v2.18 or above
  • Ember CLI v2.13 or above

Installation

  • ember install ember-addon-ember-data-model-query

or add them to the package.json and run npm install


Usage

The addon gives the user two mixins adapter-actions and model-actions. Both mixins need to be present in the model and adapter of the type to work properly.

import AdapterMixin from 'ember-addon-ember-data-model-query/mixins/adapter-actions';

export default DS.RESTAdapter.extend(AdapterMixin, {
});
import ModelMixin from 'ember-addon-ember-data-model-query/mixins/model-actions'

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

The adapter is presented of two functions: findHasMany and getDepaginated. The override of the findHasMany give the user the ability to set queryParams to the relationship get request and/or get it depaginated. Currently it works with sirenJSON and the meta property returned from the API.

The getDepaginated method on the other hand exposes the depaginated logic used in the findHasMany. Example usage:

Lets say in the model you have this property customFoo

import ModelMixin from 'ember-addon-ember-data-model-query/mixins/model-actions'

export default DS.Model.extend(ModelMixin, {
  foo: hasMany('foo'),
  customFoo: computed('foo', function() {
    //Here we want to filter the foo relationship and only return handful. 
    //The problem we are solving is that the API may have a custom QueryParam set to filter the foo and we would like to use it. But in order to do so, we need to build a proper URL based on the relationship of `foo`
    const adapter = this.store.adapterFor(this.constructor.modelName);
    const promise = adapter.getCustomFoo({ $filter: 'custom eq true' }, { depaginated: true }, this);

    return PromiseManyArray.create({
      promise: resolve(promise, 'customFooFetch')
    });
  })
});

Now in the adapter:

import AdapterMixin from 'ember-addon-ember-data-model-query/mixins/adapter-actions';

export default DS.RESTAdapter.extend(AdapterMixin, {
    getCustomFoo(queryParams = {}, options = {}, model) {
        const url = `${prefix}/parentModel/${model.get('id')}/foo`;

        return this.getDepaginated(url, parameters).then(rawResponse => {
            //Now here we have the raw response from the API and we need to normalize it and push it to the store.
        });
    }
});

In order to keep the functionality of ember-data findHasMany to use the addon you need to customize your relationship properties in the model. Currently in the options you need to pass { depaginated: true }.

import ModelMixin from 'ember-addon-ember-data-model-query/mixins/model-actions'

export default DS.Model.extend(ModelMixin, {
  foo: hasMany('foo', { depaginated: true })
});

Future ideas

  • Add option to cache the result for hasMany relationship