I have a Firestore document and want to add a field to this document of type reference
. It is a reference to another document in another collection.
Example:
We have two collections named messages
and users
. Within the collection messages
we have a document with the doc-ID msgId1
. Now we want to add a field of type reference with this doc-ID to a user document within the users
collection.
user
{
firstName: 'tessty',
lastName: 'Toast',
msg: msgId1
}
At the moment I use google-cloud-firestore for Python as follows:
user_doc = users_coll.add(user)
The problem is that this way the msgId1
is added as a string rather than a reference.
Any idea how I can set the field-type to reference programmatically in my Python script?