samuelgozi/firebase-firestore-lite

The query returns only the date fields in the document

Closed this issue · 13 comments

db.reference('users').query().run() is returning the the below response

[{
  "document": {
    "name": "projects/#######/databases/(default)/documents/users/WXUijOe1en5KASnE7KfI",
    "createTime": "2020-04-05T06:12:39.324199Z",
    "updateTime": "2020-04-05T06:21:56.163993Z"
  },
  "readTime": "2020-04-05T06:41:19.947019Z"
}
,
{
  "document": {
    "name": "projects/#######/databases/(default)/documents/users/vMP7SCo8fsoho5t6LMyt",
    "createTime": "2020-04-05T06:22:10.103592Z",
    "updateTime": "2020-04-05T06:22:16.128558Z"
  },
  "readTime": "2020-04-05T06:41:19.947019Z"
}
]

Not sure why the fields from the document are not present in the response.

Thanks for opening an issue. This indeed looks like a bug, I'll look into it.
Just out of curiosity. What were you trying to achieve with the empty query?

I've just created the users collection. Just wanted to check if this can be retrieved. As its documented that select clause is optional, if specified empty the query will return complete document

Seems like its not happening, could you please have a look into it.
Please suggest if I'm missing something...

I found the issue. A fix will be up in a few minutes.
The issue is caused due to a less known firestore feature, I believe that this feature doesn't exist In the official SDK, so I'm explaining this just because it's a cool feature, you don't really need to know :).

When making a query(and also getting a document, but the syntax is different), you can specify which properties of the document you want to be returned. This exists in order to save network bandwidth.

I misunderstood the docs and thought that if the option is left empty then it will ignore the option completely, but is it turns out I misunderstood it.

I'll close the issue when the update is up.

Oh and BTW, if you wish to retrieve a complete collection you can just do:

db.reference(“users”).get();

This request is subject to restrictions in the Firebase rules.

Fixed in version 0.4.2, make sure to update dependencies.

I found the issue. A fix will be up in a few minutes.
The issue is caused due to a less known firestore feature, I believe that this feature doesn't exist In the official SDK, so I'm explaining this just because it's a cool feature, you don't really need to know :).

When making a query(and also getting a document, but the syntax is different), you can specify which properties of the document you want to be returned. This exists in order to save network bandwidth.

I misunderstood the docs and thought that if the option is left empty then it will ignore the option completely, but is it turns out I misunderstood it.

I'll close the issue when the update is up.

Even I checked the StructuredQuery docs, there as well its mentioned - If empty, all fields are returned.

Am I referring to wrong docs? Anyways, if you fix the bug, please push it to npm

So I wasn't hallucinating. Yes, those are the docs.
Well, I guess I'll report that issue too. I think they are tired of my reports.

Thanks, Just out of curiosity - why is the commit 57b0c33 includes many unnecessary commas ...

I don't know... weird...
I have prettier set to lint on save, so that is what caused the issue, but I didn't change the project's config...

Thanks for noticing this. It would probably take me at least a few days to notice it myself. hopefully ill find a fix quickly.

prettier changed the default value for "tralingComma" from "none" to "es5" which adds commas to the last elements in objects, and probably arrays. The good news(for me) is that you spotted the first time this change took effect in any of my projects, so that's cool.

What a weird decision from their part... Anyways, its fixed.

SO is full of answers suggesting not to use trailing commas in json, it's unnecessary and may cause issues of cross browser compatibility.

Great that you fixed it, please push it to npm as well. Thanks

Fixed this and also pushed to NPM under version 0.4.3.

Great Thanks :)