Get error message when calling 'getDocument' on an empty document
Minimal code to reproduce the problem
Create an empty document (no fields) in the firestore "test_col/test_doc"
const firestore = FirestoreApp.getFirestore(email, key, projectId);
firestore.createDocument('test_col/test_doc', {});
var data = firestore.getDocument('test_col/test_doc');
Expected Behavior
'data' should be valid and 'data.obj' = {}
Actual Results
Get the error message when calling 'getDocument':
Error: No document with `fields` found at path test_col/test_doc
getDocument_ @ FirestoreRead.gs:76
getDocument @ Firestore.gs:44
Library Version:
v33
I don't think the library handles empty documents like that. I'm curious to a valid use case, @zhezhang77.
I don't think the library handles empty documents like that. I'm curious to a valid use case, @zhezhang77.
An empty document in the database indicates that a site exists but has no record right now. I understand that I can change the fields definition of the document to avoid creating an empty one, but it's a risky action to upgrade the whole database and codes in other clients (Python, C#, etc).
Since there is no restriction to create an empty document on all platforms including FirestoreApp, I think it is reasonable to read that document out without throwing any errors.