Is there any way to create a new document in Firestore and name it after a variable?
I tried modifying the example provided here but to no avail.
This is what I attempted:
import time
#declare unix variable
unix = int(time.time())
#gcp boilerplate dictionary
data = {
'name': 'Los Angeles',
'state': 'CA',
'country': 'USA'
}
#create new doc under collection with fields form dictionary
db.collection('cities').document(unix).set(data)
If you pass a document ID to
CollectionReference.document(), it has to be a string argument. It can be a hard-coded string, but it can also be a variable: as long as that variable is a string.