Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Can't apply a query to the master index #28

Closed
maksymilian-majer opened this issue Apr 1, 2015 · 7 comments
Closed

Can't apply a query to the master index #28

maksymilian-majer opened this issue Apr 1, 2015 · 7 comments

Comments

@maksymilian-majer
Copy link

I've tried applying query to the ref passed as argument to the NormalizedCollection and to the the NormalizedRef. In both cases I don't get any results.

Here are two plunks that illustrate this:

@maksymilian-majer maksymilian-majer changed the title Can't apply the query to the master index Can't apply a query to the master index Apr 1, 2015
@katowulf
Copy link
Contributor

katowulf commented Apr 1, 2015

Because of this console error:

Error: Each argument to the NormalizedCollection constructor must be a valid Firebase reference or an Array containing a Firebase ref as the first argument
    at assertPaths (firebase-util.js:696)
    at Object.NormalizedCollection (firebase-util.js:644)
    at new <anonymous> (script.js:8)
    at Object.e [as invoke] (angular.min.js:37)
    at G.instance (angular.min.js:76)
    at angular.min.js:59
    at r (angular.min.js:7)
    at J (angular.min.js:59)
    at g (angular.min.js:52)
    at angular.min.js:51

@maksymilian-majer
Copy link
Author

This console error is in the first case and it's pretty clear that I can't apply query on the Firebase reference before passing it to the NormalizedCollection. I also tested applying query to the NormalizedRef which is returned by calling ref() on the NormalizedCollection. I concluded that it's possible from the docs (https://github.com/firebase/firebase-util/blob/master/src/NormalizedCollection/README.md#query-methods).

This is demonstrated here: http://plnkr.co/edit/5AtkOtfvBorKkLnLCHAw
You'll see in the console that on('value',...) results in null being logged to the console.

@katowulf
Copy link
Contributor

katowulf commented Apr 1, 2015

No disagreement here, just adding context with the console error.

@maksymilian-majer
Copy link
Author

In that case here's the console warning from firebase-util from the second example:

FIREBASE WARNING: Exception was thrown by user callback. TypeError: undefined is not a function
    at AbstractRecord.child (https://cdn.firebase.com/libs/firebase-util/0.2.2/firebase-util.js:229:26)
    at Object.RecordList.add (https://cdn.firebase.com/libs/firebase-util/0.2.2/firebase-util.js:2099:24)
    at Object.RecordSetEventManager._add (https://cdn.firebase.com/libs/firebase-util/0.2.2/firebase-util.js:2078:18)
    at h.Mb (https://cdn.firebase.com/js/client/2.2.1/firebase.js:52:375)
    at Ab (https://cdn.firebase.com/js/client/2.2.1/firebase.js:47:165)
    at wb (https://cdn.firebase.com/js/client/2.2.1/firebase.js:22:216)
    at xb (https://cdn.firebase.com/js/client/2.2.1/firebase.js:21:1261)
    at Bh.h.Cd (https://cdn.firebase.com/js/client/2.2.1/firebase.js:194:472)
    at kh.h.Bd (https://cdn.firebase.com/js/client/2.2.1/firebase.js:182:266)
    at Zg.Bd (https://cdn.firebase.com/js/client/2.2.1/firebase.js:174:364)

Hope this will be helpful.

@katowulf
Copy link
Contributor

katowulf commented Apr 1, 2015

Looks like this is because we call .child() on the query ref. Need to .ref().child() that.

@michaeldim
Copy link

I am trying to apply a query on the master index using the orderByValue() method however with the 0.2.4 release I am getting an 'undefined is not a function' error, http://plnkr.co/edit/HaA1lz

@katowulf
Copy link
Contributor

@bogdantmm92 I've deleted your comment as it has nothing to do with this issue. Please submit a separate issue in the tracker, and be sure to include an mcve than demonstrates how you've arrived at the error. ☼, Kato

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants