Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get error message when calling 'getDocument' on an empty document #138

Open
zhezhang77 opened this issue Aug 9, 2022 · 2 comments
Open
Labels

Comments

@zhezhang77
Copy link

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

@zhezhang77 zhezhang77 added the bug label Aug 9, 2022
@LaughDonor
Copy link
Collaborator

I don't think the library handles empty documents like that. I'm curious to a valid use case, @zhezhang77.

@zhezhang77
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants