Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chainable query builder interfaces #241

Closed
wants to merge 3 commits into from

Conversation

tchak
Copy link
Member

@tchak tchak commented Dec 28, 2019

Adds chainable query builders. This is a huge DX improvement in my opinion.

Query:

store.findRecords('planet')
  .sort('classification', '-name'))
  .filter({ attribute: 'classification', value: 'terrestrial' });

Peek:

store.findRecords('planet')
  .sort('classification', '-name'))
  .filter({ attribute: 'classification', value: 'terrestrial' })
  .peek();

Live Query:

store.findRecords('planet')
  .sort('classification', '-name'))
  .filter({ attribute: 'classification', value: 'terrestrial' })
  .live();

Live Peek:

store.findRecords('planet')
  .sort('classification', '-name'))
  .filter({ attribute: 'classification', value: 'terrestrial' })
  .live()
  .peek();

@tchak
Copy link
Member Author

tchak commented Dec 28, 2019

I am planing on adding another round of deprecations with this. But everything is backward compatible.

It is also interesting to see this in conjunction with #240. It will be possible to write :

store.findRecord({ type: 'planet', id: '1' })
  .peek().hasMany('moons')
    .query()
    .sort('name')
    .live()
    .peek();

store.findRecord({ type: 'planet', id: '1' })
  .peek().hasMany('moons')
    .query()
    .page({ offset: 0, limit: 10 }));

@tchak
Copy link
Member Author

tchak commented Dec 28, 2019

This PR also alignes findRecord with EmberData to take a RecordIdentifier

@tchak tchak force-pushed the chain-query-terms branch 2 times, most recently from 31039ff to b49ab1f Compare December 28, 2019 13:25
@tchak tchak changed the title Add chainable query interfaces Add chainable query builder interfaces Dec 28, 2019
@tchak
Copy link
Member Author

tchak commented Dec 28, 2019

I added live interface only to findRecords and findRelatedRecords to mitigate #178. We can revisit this later when we have a better solution for LiveQuery.

@tchak
Copy link
Member Author

tchak commented Jul 5, 2020

superseded by #278

@tchak tchak closed this Jul 5, 2020
@tchak tchak mentioned this pull request Jul 5, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant