Reputation: 892
I need some help designing the Firestore database for my app. The app has three requirements:
The first requirement is straight forward using a Firestore query.
The second requirement I’m planning to have a “position” field in the documents so the query can be “ordered by” the “position” field.
It’s the third requirement where I have difficulties. My first thought is to is to have multiple “position” fields associated with each user and order the query by the “user’s position” field. However, since Firestore requires an index for each query this approach does not work.
Any suggestions as to how best to design my Firestore database to accomplish the app’s three requirements would be appreciated.
Upvotes: 1
Views: 660
Reputation: 892
For anyone else that is interested, below describes my changes:
Hope this helps.
Upvotes: 0
Reputation: 317392
You could store each user's ordering in a per-user document or collection (organized separately from the data itself). Simply map each document id to that user's chosen position for it. This means you would also need a separate query to get that ordering, but you wouldn't need a new index at all.
Upvotes: 1