Here's the syntax I used, I encounter an exception when the third line is executed.
fire_client = firestore.Client()
def_ref = fire_client.collection('collection_parent').document('document1').set({"key":"value"})
msg_ref = def_ref.collection('collection_child').document('document2').set({"key1":"value1"})
CodePudding user response:
The .set() method returns a WriteResult that does not have a collection() method. So def_ref.collection(...) throws that exception. Try refactoring the code as shown below:
fire_client = firestore.Client()
def_ref = fire_client.collection('collection_parent').document('document1')
def_ref.set({"key":"value"})
msg_ref = def_ref.collection('collection_child').document('document2')
msg_ref.set({"key1":"value1"})
