Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataToMap ¶ added in v0.44.0
DataToMap converts record data into a map[string]any keyed by field name.
A map[string]any is returned unchanged. Any other value (typically a struct or a pointer to a struct) is converted via encoding/json, after which the top-level keys are remapped so a field's `db` tag takes precedence over its `json` tag. This lets file/document adapters that lack a native serializer (unlike the Firestore SDK or scany for SQL) reuse one consistent mapping.
Tag precedence for a field key is: `db` tag, then `json` tag, then field name. `json:"-"` fields are omitted and `,omitempty` is honoured (both via the json round-trip). Nested struct fields are serialized by encoding/json and therefore follow their `json` tags.
func MapToData ¶ added in v0.44.0
MapToData populates target from src. If target is a map[string]any, src is copied into it. Otherwise target must be a pointer (typically to a struct): the `db`-keyed entries in src are remapped back to `json` keys and applied via encoding/json, so values, nested structs and type coercion are handled by the standard library. Tag precedence matches DataToMap: `db`, then `json`, then field name.
Types ¶
type DataWithID ¶ added in v0.2.30
type DataWithID[K comparable, D any] struct { WithID[K] Data D // we can't use *D here as consumer might want to pass an interface value instead of a pointer }
func NewDataWithID ¶ added in v0.2.30
func NewDataWithID[K comparable, D any](id K, key *dal.Key, data D) DataWithID[K, D]
type WithID ¶
type WithID[K comparable] struct { ID K `json:"id"` // Unique id of the record in collection FullID string `json:"fullID,omitempty"` // Custom id of the record fully unique across all DB collections Key *dal.Key `json:"-"` Record dal.Record `json:"-"` }
WithID is a record with a strongly typed ID
type WithRecordChanges ¶ added in v0.14.0
type WithRecordChanges struct {
RecordsToUpdate []*Updates
RecordsToDelete []*dal.Key
// contains filtered or unexported fields
}
func (*WithRecordChanges) ApplyChanges ¶ added in v0.14.0
func (v *WithRecordChanges) ApplyChanges(ctx context.Context, tx dal.ReadwriteTransaction, excludeKeys ...*dal.Key) (err error)
func (*WithRecordChanges) QueueForInsert ¶ added in v0.14.0
func (v *WithRecordChanges) QueueForInsert(records ...dal.Record)
func (*WithRecordChanges) RecordsToInsert ¶ added in v0.14.0
func (v *WithRecordChanges) RecordsToInsert() (records []dal.Record)