pgollangi / FireQL

Interactive CLI and Go library to query Google Firestore database using SQL syntax.
https://pgollangi.github.io/FireQL/
MIT License
31 stars 1 forks source link

Getting Document ID with SELECT query. #14

Closed SergeyRim closed 10 months ago

SergeyRim commented 1 year ago

Is your feature request related to a problem? Please describe. Want be able to get Document ID with SELECT query

Describe the solution you'd like A FireSQL library provided an option to to obtain the document IDs when doing a SELECT * query with parameter: "includeId: true" // To include Document ID as "_ name _" field Will be good to have the same functionality with FireQL.

Additional context Really need this feature to use with Firestore grafana plugin.

jonathanbakley commented 1 year ago

This would be super helpful. I am in a similar situation as @SergeyRim where I would like to use this with the Firestore grafana plugin.

pgollangi commented 10 months ago

@SergeyRim It would be clean to select document Id using __name__ column. I'll add that support.

For example, below query selects document id:

select __name__ from ...

would that work?

SergeyRim commented 10 months ago

@pgollangi Thank you for your hard work and plans to add this functionallity.

It would be nice if __name__ will be also returned in "select * from..." since sometimes it's important to get all the fields including __name__ in one select.

Thanks.

pgollangi commented 10 months ago

@SergeyRim implicitly selecting ID on * selection will eliminate the ability to exclude ID on selecting *. People may not want to see random generated document ID on selecting all fields.

While on-demand inclusion of ID using __name__ column would suffice both the scenarios.

I can add a global option to fireql programmable API interface to select ID in all select queries run with it, but that wouldn't be useful for queries running Grafana plugin.

Thoughts?

SergeyRim commented 10 months ago

@pgollangi if the query select __name__, * from ... will works, it will be the best solution I suppose.

Thank you.

pgollangi commented 10 months ago

Ofcourse yes, you can do that.

jonathanbakley commented 10 months ago

Thank you so much for adding this @pgollangi!

SergeyRim commented 10 months ago

@pgollangi Can the grafana Firestore plugin be updated? Or how can upgrade it manually with the latest changes in FireQL?

pgollangi commented 10 months ago

I need to release the plugin update with latest FireQL which will by reviewed by Grafana team. Once the plugin update is approved by Grafana team, it will be available for everyone on Grafana instances to upgrade.

They generally take up to 2 days to approve a plugin update.

I'm going to submit the Grafana plugin update today.

SergeyRim commented 10 months ago

@pgollangi much appreciated

pgollangi commented 10 months ago

A new version of Grafana plugin submitted which includes this change. https://github.com/pgollangi/firestore-grafana-datasource/releases/tag/v0.2.6

Please give it a star and share if you think FireQL and Grafana Plugin is useful to you!

Thanks!