Documentation
¶
Overview ¶
Package firestorebind parses and prints typed Firestore Datastore access-pattern sources.
The grammar is the .tb.dynamo one with the parts Datastore does not have removed and the parts it does have added. It declares no kind: a kind belongs to the type, not to the deployment, so the result type already says it. That is the one structural difference from the DynamoDB grammar, and it is why the two stay separate packages rather than one with a mode flag.
Index ¶
Constants ¶
const DefaultTemplatePattern = "*.tb.firestore"
DefaultTemplatePattern is the base-name glob for query declarations, beside the HTML, SQL and DynamoDB template patterns.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bound ¶
type Bound struct {
// Literal is the constant form; Param names a parameter instead. Exactly one
// is set when Present is true.
Literal int
Param string
Present bool
Line int
}
Bound is a limit or an offset, which is either a literal or a parameter.
type Condition ¶
Condition is one node of a where clause: either a comparison or a junction of other conditions.
A where clause is a tree rather than a list because Datastore composes with both AND and OR. It was AND-only when this grammar was written, and the parser said so while rejecting or; the driver gained OR in tinygodriver v1.1.6 after this side asked whether the claim still held.
Exactly one of Predicate and Operands is set. A leaf carries the comparison; a junction carries its operands and the word that joins them.
func (Condition) Flatten ¶
Flatten returns the leaves of an all-and tree, and reports whether the tree is one. The emitter uses it to keep the common declaration generating the same per-predicate Filter calls it always has.
func (Condition) HasOr ¶
HasOr reports whether any junction below this one is an or, which is what decides whether generated code needs the condition tree at all.
type IndexProperty ¶
IndexProperty is one property of a declared composite index.
type Projection ¶
Projection is one property a select clause returns.
type QueryDecl ¶
type QueryDecl struct {
Name string
Exported bool
Params []QueryParam
Shape ResultShape
EntityType string
// Where is the filter tree, or nil when the declaration has no where clause.
Where *Condition
// Ancestor names the parameter holding the ancestor key, when the
// declaration has an ancestor clause.
Ancestor string
AncestorLine int
Order []Order
Limit Bound
Offset Bound
// Select is the projection: the properties the query returns instead of
// whole entities. The result type is unchanged; what is not projected
// arrives as the zero value.
Select []Projection
SelectLine int
// Distinct collapses results sharing the named properties.
Distinct []Projection
DistinctLine int
// Start and End name the parameters holding the cursors this query resumes
// from and stops at.
Start string
StartLine int
End string
EndLine int
// Index is the composite index this access pattern needs, when the author
// declared one. Nothing derives it: the rule for when one is required is
// subtle, and a derivation that is quietly wrong names an index that does
// not fix the query.
Index []IndexProperty
IndexLine int
// HasIndex separates a declared empty index from no index clause.
HasIndex bool
SourcePath string
Line int
}
QueryDecl is one declared access pattern.
It names no kind. The result type names the bound Go type, and that type's generated Kind method is the kind, so a declaration cannot disagree with the codec about what it is querying.
type QueryParam ¶
type QueryParam struct {
Name string
// Type is the Go type as the declaration spells it, checked later against
// the property's own Go type.
Type string
Line int
}
QueryParam is one declared parameter of a query function.
type ResultShape ¶
type ResultShape string
ResultShape is what a declaration asks the generated function to return. It selects the request shape rather than a row count: a query always returns many, and the choice is whether the caller sees the batch boundaries.
const ( // Batch issues one request and returns a page. Batch ResultShape = "batch" // Many iterates every batch. Many ResultShape = "many" // Count runs an aggregation query and decodes no entity. Count ResultShape = "count" // Keys runs a keys-only query, which is the cheap way to test existence in // bulk. Keys ResultShape = "keys" )