firebasefirebase-realtime-databasepolymer-1.0firebase-polymer

Using firebase-query with Polymerfire?


Before anyone makes a comment about me not trying to figure things out on my own.

I have read through those firebase docs (https://firebase.google.com/docs/reference/js/firebase.database.Query) about 3 times today. I also read through the source code ( e.g. https://github.com/firebase/polymerfire/blob/master/firebase-query.html) about 3 times today.

I essentially have data setup like this:

{
Logs: {
$uid: {
$logID:{
logMetaData}}},

Users: {
$uid:{
userMetaData}},

Groups: {
admin: {
members: {
$uid}},
users: {
members: {
$uid}}}
}

I’m trying to use firebase-query like this:

<firebase-query
      id="adminLogQuery"
      app-name="Nuclear Medicine Log"
      path="/Logs/"
      orderByChild="Authorized User"
      equalTo="{"[[user.displayName]]":"Authorized User"}
      data="{{data}}">
</firebase-query>

Essentially, within the logMetaData, there is a key called Authorized User and I want to match the user.displayName to the values for the Authorized User.

I would like to define path="Logs/[[uid]/[[logId]]" but I’m not sure how I would have uid or logID defined (or pre-defined) as properties, since there are so many entries that vary. The uid is a scramble of letters and numbers, while the logID are timestamps

I’m not sure if orderByChild traverses multiple levels that are deep to the root.


Solution

  • Polymer attributes don't follow camel case naming. So orderByChild should be order-by-child. And equalTo should be equal-to.