nicklandgrebe / active-resource.js

ActiveResource.js - API resource relational mapping in JavaScript
https://active-resource.js.org
MIT License
133 stars 20 forks source link

Getting relations using filtering strategy #33

Closed antonkomarev closed 5 years ago

antonkomarev commented 5 years ago
Project.find('1').then(project => {
    project.tasks().all();
});

This code produces query: /projects/1/tasks

But I need to utilize filters instead: /tasks?filter[project][type]=Project&filter[project][id]=1

Is there is an easy way to do it?

nicklandgrebe commented 5 years ago

project.tasks().where({ project: { type: 'Project', id: '1' }})

Though why, if you are requesting /projects/1, do you need to specify the project id? Or the type for that matter?

antonkomarev commented 5 years ago

I don't need to have /projects/1 in my URI. My URI: http://localhost/tasks?filter[project][type]=Project&filter[project][id]=1