Documentation ¶
Index ¶
- Constants
- Variables
- func BatchSet[T Identifiable](ctx context.Context, client *firestore.Client, col string, items ...T) error
- func Delete(ctx context.Context, client *firestore.Client, col, id string) error
- func Get[T any](ctx context.Context, client *firestore.Client, col, id string) (*T, error)
- func GetClient(ctx context.Context, projectID string) (client *firestore.Client, err error)
- func GetClientOrPanic(ctx context.Context, projectID string) *firestore.Client
- func GetCollection(client *firestore.Client, name string) (col *firestore.CollectionRef, err error)
- func Query[T any](ctx context.Context, client *firestore.Client, c *Criteria) ([]*T, error)
- func Save[T any](ctx context.Context, client *firestore.Client, col, id string, in *T) error
- func ToStructs[T any](it *firestore.DocumentIterator) ([]*T, error)
- func ToStructsWithHandler[T any](it *firestore.DocumentIterator, h func(item *T) (bool, error)) ([]*T, error)
- func Update(ctx context.Context, client *firestore.Client, col, id string, ...) error
- type Criteria
- type Criterion
- type Identifiable
- type OperationType
Constants ¶
View Source
const (
// MaxBatchSize is the maximum number of items that can be batched together.
MaxBatchSize = 500
)
Variables ¶
View Source
var ( // ErrDataNotFound is thrown when query does not find the requested data. ErrDataNotFound = errors.New("data not found") )
View Source
var ( // ErrInvalidDestinationType is thrown when the item type is not a pointer to a struct. ErrInvalidDestinationType = errors.New("destination type must be a non nil pointer") )
Functions ¶
func GetClientOrPanic ¶ added in v0.4.3
GetClientOrPanic returns instantiated Firestore client or panics on error.
func GetCollection ¶ added in v0.3.1
GetCollection returns specific store collection by name.
func ToStructs ¶ added in v0.3.2
func ToStructs[T any](it *firestore.DocumentIterator) ([]*T, error)
ToStructs converts the Firestore document iterator into a slice of structs.
func ToStructsWithHandler ¶ added in v0.4.1
func ToStructsWithHandler[T any](it *firestore.DocumentIterator, h func(item *T) (bool, error)) ([]*T, error)
ToStructsWithHandler converts the Firestore document iterator into a slice of structs.
Types ¶
type Criteria ¶ added in v0.3.1
type Criteria struct { Collection string Criterions []*Criterion OrderBy string Desc bool Limit int }
Criteria represents a query to be executed against the Firestore.
type Criterion ¶ added in v0.1.1
type Criterion struct { Path string Operation OperationType Value interface{} }
Criterion represents a single criteria for a query.
type Identifiable ¶ added in v0.4.1
type Identifiable interface {
GetID() string
}
type OperationType ¶ added in v0.1.1
type OperationType string
OperationType represents the type of operation to be performed.
const ( // OperationTypeEqual is equal to. OperationTypeEqual OperationType = "==" // OperationTypeNotEqual is not equal to. OperationTypeNotEqual OperationType = "!=" // OperationTypeLessThan is less than. OperationTypeLessThan OperationType = "<" // OperationTypeLessThanOrEqual is less than or equal to. OperationTypeLessThanOrEqual OperationType = "<=" // OperationTypeGreaterThan is greater than. OperationTypeGreaterThan OperationType = ">" // OperationTypeGreaterThanOrEqual is greater than or equal to. OperationTypeGreaterThanOrEqual OperationType = ">=" // OperationTypeArrayContains is array contains. OperationTypeArrayContains OperationType = "array-contains" // OperationTypeArrayContainsAny is array contains any. OperationTypeArrayContainsAny OperationType = "array-contains-any" // OperationTypeIn is in. OperationTypeIn OperationType = "in" // OperationTypeNotIn is not in. OperationTypeNotIn OperationType = "not-in" )
Click to show internal directories.
Click to hide internal directories.