0

I have set up all the currently needed Fields in my firestore collection documents, but I fear I may need to add new fields later in future as the usage of the app grows.

My question is, will I need to delete the whole collection just to add another new field in future? or will i simply add a new field thereby changing the structure of all the future documents that will be created in the collection.

Thanks

2 Answers2

1

I fear I may need to add new fields later in future as the usage of the app grows.

It happens all the time. Is normal. As the app grows, new features are needed.

Will I need to delete the whole collection just to add another new field in future?

No and never think about that. You can simply update each document with the new properties that you need. You can easily do that using a POJO class, as explained in my anwer from this post or even simpler using a Map, as explained here.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
0

Firestore, like most NoSQL databases, is schema-less. This means there is no structure to the data you put in it. The only structure is that which you impose by your own code. You could have millions of documents in a collection that all have completely different fields, and they will not conflict with each other in any way. You can add and remove fields at any time. You choose whatever suits your application the best.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441