GQL Query Select Kind with name default

Viewed 165

I have firestore data structure like this:

my firestore data structure

How to achieve to get ts_app_theme with name default only?

I already try query like this

SELECT * FROM ts_app_theme WHERE __key__ HAS ANCESTOR KEY(ts_app_config, '$merchant_key') AND __key__ = KEY(ts_app_theme, 'default')

it didn't work..

I can do this

SELECT * FROM ts_app_theme WHERE __key__ HAS ANCESTOR KEY(ts_app_config, '$merchant_key')

but will return another document in ts_app_theme if I have more document other than default later..

Thank you..

1 Answers

GQL is for Firestore in Datastore mode. You can find it in Google docs here and here. Datastore data model has kind which that might be compared to SQL table and entity which can be compared to SQL row. Due to this structure it's possible to use SQL like querying.

While Firestore in general, like on your screenshot, is NoSQL database. As of it concept it does not contain schema which is could be use in building SQL queries. BTW I wonder where you run those queries, possible there is some nice tool I don't know of.

Regarding querying Firestore I found nice tutorial series starting with this.

Related