Documentation ¶
Index ¶
- Variables
- func NewClient(ctx context.Context, googleProject string) *firestore.Client
- type ErrMismatchedTypes
- type ErrNegativePageSize
- type FireProto
- func (f *FireProto) BatchReadProtos(ctx context.Context, resourceNames []string, messageType proto.Message, ...) ([]proto.Message, error)
- func (f *FireProto) DeleteRow(ctx context.Context, resourceName string) error
- func (f *FireProto) PageProtos(ctx context.Context, messageType proto.Message, opts PageOptions) ([]proto.Message, string, error)
- func (f *FireProto) ReadProto(ctx context.Context, resourceName string, message proto.Message, ...) error
- func (f *FireProto) UpdateProto(ctx context.Context, resourceName string, columnFamily string, ...) error
- func (f *FireProto) WriteProto(ctx context.Context, resourceName string, message proto.Message) error
- type PageOptions
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFieldMask = errors.New("invalid field mask")
Functions ¶
func NewClient ¶
NewClient returns a firestoreproto object, containing an initialized client connection using the project as connection parameters It is recommended that you call this function once in your package's init function and then store the returned object as a global variable, instead of making new connections with every read/write.
Types ¶
type ErrMismatchedTypes ¶
func (ErrMismatchedTypes) Error ¶
func (e ErrMismatchedTypes) Error() string
type ErrNegativePageSize ¶
type ErrNegativePageSize struct{}
func (ErrNegativePageSize) Error ¶
func (e ErrNegativePageSize) Error() string
type FireProto ¶
type FireProto struct {
// contains filtered or unexported fields
}
FireProto offers a simple interface for reading and writing protobuf messages to Firestore.
func NewFireProto ¶
NewFireProto returns a new FireProto object, containing the provided Firestore client for use in inter
func NewTestFireProto ¶
func NewTestFireProto() *FireProto
func (*FireProto) BatchReadProtos ¶
func (f *FireProto) BatchReadProtos(ctx context.Context, resourceNames []string, messageType proto.Message, readMask *fieldmaskpb.FieldMask) ([]proto.Message, error)
BatchReadProtos returns the list of protos for a specified set of resourceNames. The order of the response is consistent with the order of the resourceNames. Also, if a particular resourceNames is not found, the corresponding response will be a nil entry in the list of messages returned.
func (*FireProto) DeleteRow ¶
DeleteRow deletes an entire document from firestore for the provided resourceName.
func (*FireProto) PageProtos ¶
func (f *FireProto) PageProtos(ctx context.Context, messageType proto.Message, opts PageOptions) ([]proto.Message, string, error)
PageProtos enables paginated list requests. if opts.maxPageSize is 0 (default value), 100 will be used.
func (*FireProto) ReadProto ¶
func (f *FireProto) ReadProto(ctx context.Context, resourceName string, message proto.Message, readMask *fieldmaskpb.FieldMask) error
ReadProto obtains a Firestore document for the provided resourceName, unmarshalls the value, applies the read mask and stores the result in the provided message pointer.
func (*FireProto) UpdateProto ¶
func (f *FireProto) UpdateProto(ctx context.Context, resourceName string, columnFamily string, message proto.Message, updateMask *fieldmaskpb.FieldMask) error
UpdateProto obtains a Firestore document for the provided resource name and unmarshalls the value to the type provided. It then merges the updates as specified in the provided message, into the current type, in line with the update mask and writes the updated proto back to Firestore. The updated proto is also stored in the provided message pointer.
func (*FireProto) WriteProto ¶
func (f *FireProto) WriteProto(ctx context.Context, resourceName string, message proto.Message) error
WriteProto writes the provided proto message to Firestore using the provided document name. The document name must conform to the convention {collection}/{resourceID} For example, books/book123 or books/book123/chapters/chapterABC
type PageOptions ¶
type PageOptions struct { PageSize int32 NextToken string MaxPageSize int32 ReadMask *fieldmaskpb.FieldMask // contains filtered or unexported fields }