Wednesday 2 December 2020

In Firebase's realtime Database, does `equalTo(arg)` only work if arg is an object?

db1:

a: {
  b: {
    c: "d"
  }
}

db2:

a: {
  b: "c"
}

db.ref(`a/b`).orderByKey().equalTo('c').on('value', (e) => {
  console.log(e.val()); 
})

When referencing db1, e.val() returns {c: "d"}.

When referencing db2, e.val() returns null. Why is this?


Some more experiments:

db.ref(`a/b`).orderByKey().on('value', (e) => { 
  console.log(e.val()); 
})

When referencing db1 & db2, returns {b: "c"} & "c" respectively.


From this, I can only guess that, for some reason, equalTo(arg) doesn't like to deal with args that're not objects.



from In Firebase's realtime Database, does `equalTo(arg)` only work if arg is an object?

No comments:

Post a Comment