TugQL

Query Firestore with TugQL

Write a SQL-like TugQL read for a Firestore collection, then resolve it with an authorized schema and the DALgo Firestore adapter.

Start with a collection you control

Assume an application already has a root Firestore collection named products with a Boolean active field. This is an illustrative schema, not a public dataset or a claim about your Firestore project. The application supplies the authorized collection and fields to TugQL resolution, enforces its own read policy, and provides credentials to its Firestore client. The adapter alone does not establish that policy.

Write the TugQL read

from products as p
where p.active = true

This is TugQL text, not a SQL statement sent to Firestore. With no select clause, resolution expands the fields authorized for the caller. The Go TugQL parser and resolver require an authorized schema before lowering the query to DALgo's structured model. Replace products and active with names from your own schema.

Bind the adapter and check capabilities

  1. Provide an authorized schema for the collection to ResolveTugQL. The Go tutorial shows the parse and resolve calls.
  2. Create a credentialed Firestore client and pass it to a DALgo database backed by dalgo2firestore. Enforce your application's read policy outside this adapter.
  3. Execute the resolved read query and handle errors. The adapter maps supported collection, filter, order and paging forms to Firestore queries.

The current Firestore adapter query path explicitly rejects GROUP BY and HAVING. A TugQL construct supported by the language is not automatically supported by this adapter. Consult the adapter source and test your exact query before publishing a runnable example or result. QueryDock's SQL playground does not connect to your Firestore project or execute TugQL.

All documentation