Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRegisterModel ¶
func MustRegisterModel(m ReadableModel)
func RegisterModel ¶
func RegisterModel(m ReadableModel) error
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client provides access to Firestore via the Calcifer ODM.
func (*Client) Collection ¶
func (c *Client) Collection(path string) *CollectionRef
func (*Client) RunTransaction ¶
func (c *Client) RunTransaction(ctx context.Context, f func(context.Context, *Transaction) error, opts ...TransactionOption) (err error)
type CollectionRef ¶
type CollectionRef struct { // Use the methods of Query on a CollectionRef to create and run queries. Query // contains filtered or unexported fields }
func (*CollectionRef) Doc ¶
func (c *CollectionRef) Doc(id string) *DocumentRef
func (*CollectionRef) NewDoc ¶
func (c *CollectionRef) NewDoc() *DocumentRef
NewDoc returns a DocumentRef with a uniquely generated ID.
type DocumentIterator ¶
type DocumentIterator struct {
// contains filtered or unexported fields
}
func (*DocumentIterator) GetAll ¶
func (it *DocumentIterator) GetAll(ctx context.Context, p any) error
func (*DocumentIterator) Next ¶
func (it *DocumentIterator) Next(ctx context.Context, p MutableModel) error
Next fetches the next result from Firestore, and unmarshals it into p. If error is iterator.Done, no result is unmarshalled. Once Next returns Done, all subsequent calls will return Done.
type DocumentRef ¶
type DocumentRef struct { *firestore.DocumentRef // contains filtered or unexported fields }
func (*DocumentRef) Collection ¶
func (d *DocumentRef) Collection(id string) *CollectionRef
func (*DocumentRef) Delete ¶
func (d *DocumentRef) Delete(ctx context.Context) error
Delete removes from Firestore the document at the path referred to by d if it exists.
func (*DocumentRef) Get ¶
func (d *DocumentRef) Get(ctx context.Context, p MutableModel) error
Get fetches the document referred to by d from Firestore, and unmarshals it into p.
func (*DocumentRef) Set ¶
func (d *DocumentRef) Set(ctx context.Context, m ReadableModel) error
Set writes a Model to Firestore at the path referred to by d.
type Model ¶
type Model struct { ID string `calcifer:"id" json:"id"` CreateTime time.Time `calcifer:"create_time" json:"create_time"` UpdateTime time.Time `calcifer:"update_time" json:"update_time"` }
A Model is a Go-native representation of a document that can be stored in Firestore. Embeded `Model` into your own struct to define other types of models.
type MutableModel ¶
type MutableModel interface {
// contains filtered or unexported methods
}
The MutableModel interface is satisfied only by pointers to calcifer.Model and structs that embed it.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query represents a Firestore query.
Query values are immutable. Each Query method creates a new Query; it does not modify the old.
func (Query) Documents ¶
func (q Query) Documents(ctx context.Context) *DocumentIterator
Documents returns an iterator over the query's resulting documents.
func (Query) Limit ¶
Limit returns a new Query that specifies the maximum number of first results to return. It must not be negative.
func (Query) LimitToLast ¶
LimitToLast returns a new Query that specifies the maximum number of last results to return. It must not be negative.
func (Query) OrderBy ¶
OrderBy returns a new Query that specifies the order in which results are returned. A Query can have multiple OrderBy/OrderByPath specifications. OrderBy appends the specification to the list of existing ones.
The path argument can be a single field or a dot-separated sequence of fields, and must not contain any of the runes "˜*/[]".
To order by document name, use the special field path DocumentID.
func (Query) Where ¶
Where returns a new Query that filters the set of results. A Query can have multiple filters. The path argument can be a single field or a dot-separated sequence of fields, and must not contain any of the runes "˜*/[]". The op argument must be one of "==", "!=", "<", "<=", ">", ">=", "array-contains", "array-contains-any", "in" or "not-in".
type Queryer ¶
type Queryer interface {
// contains filtered or unexported methods
}
A Queryer is a Query or a CollectionRef. CollectionRefs act as queries whose results are all the documents in the collection.
type ReadableModel ¶
type ReadableModel interface {
// contains filtered or unexported methods
}
The ReadbleModel interface is satisfied only by calcifer.Model and structs that embed it.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func (*Transaction) Delete ¶
func (tx *Transaction) Delete(dr *DocumentRef) error
func (*Transaction) Documents ¶
func (tx *Transaction) Documents(q Queryer) *DocumentIterator
func (*Transaction) Get ¶
func (tx *Transaction) Get(dr *DocumentRef, m MutableModel) error
func (*Transaction) Set ¶
func (tx *Transaction) Set(dr *DocumentRef, m ReadableModel) error
type TransactionOption ¶
type TransactionOption any