samuk190 / localbase

A Firebase-Style Database ... Offline!
636 stars 84 forks source link

fix: when collection does not have property, should still sort #44

Closed eugenethered closed 3 months ago

eugenethered commented 3 years ago

There's an issue when collection does not have a property when performing orderBy.

For example: Let's say you store multiple entities... as cats.

  1. {name: "socks", born: "2001"}
  2. {name: "ginger"}
  3. {name: "furball, born: "2020"}

If you use the existing code and try orderBy('born') it will explodešŸ’„ because the property "born" for ginger does not exist.

The fix Essentially it just does a simple check that both compared entities, both have the desired property.

Hope this helps.

samuk190 commented 3 months ago

I've tested here, confirmed it is working, going to release this on next release!