question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't combine startAt(), endAt()…

See original GitHub issue

I’m trying to find the last couple of records (tracks from a playlist) using this code:

return this.store.find('track', {
  orderBy: 'playlist',
  equalTo: '-J_somefirebaseid'
});

… but I get the following error:

Error while processing route: channel.index.index Query: Can’t combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.

Error: Query: Can’t combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.

Doing playlist.get('tracks') works, but I don’t want to load ALL those tracks. Only the last ten.

I’m on Ember 1.11.0, Ember Data 1.0.0-beta.16.1 and EmberFire 1.4.4.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
tstirratcommented, Apr 17, 2015

Thats a good question. You could get the hasMany relationship array and then .filter it on the client side.

But, I know you’re really asking about doing it via server call. There isn’t a way that I know of off the top of my head.

Even if we got realtime updates via findQuery as requested in #235, this would still not allow equalTo + limitToX

I wonder, for advanced situations if you could create a ref on the hasMany key for the model and when a child changes you can update the array manually… something like this (might need some adjustment):

var adapter = this.store.adapterFor('playlist');
adapter._geRef('playlist').child(model.id).child('tracks')
  .orderByKey()
  .limitToLast(5)
  .on('value', (snapshot) => {
    var ids = Object.keys(snapshot.val());
    var requests = ids.map((id) => {
      return this.store.find('track', id);
    });
    Ember.RSVP.all(requests).then((tracks) => {
      this.set('last5Tracks', tracks); // might need an Ember.run wrap
    });
  });
0reactions
xe4mecommented, Jun 3, 2018

I’ve been finding the “filter it in the client” answer in different places, This is the most retarded answer ever. Download the whole database,and the filter it on the client , thank you very much>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Can't call startAt() or equalTo() multiple times
When I want to restrict the data I'm looking for with query to startAt () and endAt () , the application crashes and...
Read more >
Can't combine startAt(), endAt()… · Issue #243 - GitHub
I'm trying to find the last couple of records (tracks from a playlist) using this code: return this.store.find('track', ...
Read more >
Firebase Cloud Firestore Querying Filtering Data for Web
Learn how to Query, Filter, and Sort Document Data from Firebase Cloud Firestore Collection Using Vanilla JavaScript.
Read more >
Retrieving Data | Firebase Realtime Database - Google
For example, you can combine the StartAt() and EndAt() methods to limit the results to a specified range of values. Even when there...
Read more >
Work with Lists of Data | FlutterFire
Use the push() method to append data to a list in multiuser applications. ... For example, you can combine the startAt() and endAt()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found