-1

I want to ask which is best for this case to implement in Firestore?

For instance, I have a list of transactions. In this list, I want to:

  1. Query and Sort.
  2. Full-text search using Algolia.
  3. Apply rules.

Should I use root collection which contains all transactions from all users, or create a sub-collection named transactions in each user?

A solution I look at should be efficient at cost and performance.

I have read:

But no mention for Algolia. I also have read Algolia docs, but there is no tutorial on how to implement Algolia search on sub-collection using the firebase extension.

Darari Nur Amali
  • 465
  • 3
  • 13

1 Answers1

2

If you want to index documents in a sub-collection you can use a wildcard as shown below:

users/{userId}/transactions

It's mentioned in the extension's Github home page here.


About root level collection vs sub-collections, you can check this answer by @Alex:

What are the benefits of using a root collection in Firestore vs. a subcollection?

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84