0

I'm a beginner creating an mobile app with react-native and firebase. I have a value stored in many documents and i want to update the value in all the documents

i tried with .where() clause but i got an error

firebase.firestore().collection('myCollection').where('myValue','==','oldValue').update({myValue:newValue});

I expected the data changed but i got this warning:

Possible Unhandled Promise Rejection (id: 0):
TypeError: _reactNativeFirebase.default.firestore(...).collection(...).where(...).update is not a function

Please excuse my bad english

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
itishermann
  • 27
  • 1
  • 10

1 Answers1

1

Firestore doesn't provide a way to update documents in bulk based on their current values. There is no SQL-like "update where" type of syntax. You'll have to first query and read all the documents you want to change, then update them with their new values.

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