samedhi / firemore

Firebase + Clojure -> Firemore
https://firemore.org/
MIT License
19 stars 3 forks source link

Array <=> Set #1

Closed samedhi closed 4 years ago

samedhi commented 5 years ago

So Firestore appears to have the notion of an array that can be used for fast containment lookups in queries. This is most similar in functionality to the default of sets in clojure. I am thinking that the "array like thing" in Firestore should be bidirectionally convertible to a clojure set in Firemore.

samedhi commented 5 years ago

https://firebase.google.com/docs/firestore/query-data/queries#array_membership - I think this should be the only support for Arrays. I am also thinking that vectors should be disabled on the clojure side within firestore documents; any vector can be represented with a map using index's as keys. Reserve "array like things" for sets to make conversion simple.

samedhi commented 5 years ago

https://cloud.google.com/firestore/docs/concepts/data-types

samedhi commented 4 years ago

you would need to support (at most)

;; AND array-contains -> ["regions" :contains "east-coast"]

;; OR (Only one per query) in -> ["country" :in #{"USA" "JAPAN"}] ;; in expands to 1 or more == array-contains-any -> ["regions" :contains-any #{"east-coast" "west-coast"}] ;; array-contains-any expands to one or more array-contains

Huh, so now there are only two real ways to manipulate 'arrays'. And they are both set centric. I think it really does make sense to make this true. It should only be sets. They are weird sets in that they maintain their ordering, but whatever.

samedhi commented 4 years ago

Chose to do the simplest transfer of this feature to firemore. Just stuck with the "broken" metaphor that Firestore has with arrays. Not dealing with issue of in place updating and deleting elements of the array. You can just re-write the entire array every time.