Versions in this module Expand all Collapse all v4 v4.0.8 Nov 14, 2024 v4.0.7 Aug 28, 2023 v4.0.6 Aug 24, 2023 v4.0.5 Jul 26, 2023 v4.0.4 Jul 26, 2023 v4.0.3 Jul 26, 2023 v4.0.2 Jul 26, 2023 v4.0.1 Sep 6, 2022 v4.0.0 Sep 6, 2022 Changes in this version + const ArrayType + const AutoType + const BooleanType + const FloatType + const IntType + const ObjectType + const RawType + const StringType + const TimeType + var Base32Encoder = func(src []byte) (string, error) + var Base58Encoder = func(src []byte) (string, error) + var Base64Encoder = func(src []byte) (string, error) + var CollectionNotFound = errors.New(`Collection not found`) + var DefaultFieldCodec = `json` + var DefaultIdentityField = `id` + var DefaultStructIdentityFieldName = `ID` + var FieldNestingSeparator string = `.` + var FieldNotFound = errors.New(`Field not found`) + var HexEncoder = func(src []byte) (string, error) + var IntIsProbablyUnixEpochSeconds int64 = 4294967296 + var RecordStructTag = util.RecordStructTag + func AddConnectionSchemeAlias(from string, to string) + func CurrentTime(value interface{}, op FieldOperation) (interface{}, error) + func CurrentTimeIfUnset(value interface{}, op FieldOperation) (interface{}, error) + func GenerateUUID(value interface{}, _ FieldOperation) (interface{}, error) + func IsCollectionNotFoundErr(err error) bool + func IsExistError(err error) bool + func IsFieldNotFoundErr(err error) bool + func IsNotExistError(err error) bool + func ShouldCreateCollection(collection *Collection, errs ...error) bool + func TrimSpace(value interface{}, _ FieldOperation) (interface{}, error) + func ValidateIsURL(value interface{}) error + func ValidateNonZero(value interface{}) error + func ValidateNotEmpty(value interface{}) error + func ValidatePositiveInteger(value interface{}) error + func ValidatePositiveOrZeroInteger(value interface{}) error + type Backend interface + GetCollection func(collection string) (*Collection, error) + type Collection struct + AllowMissingEmbeddedRecords bool + AlwaysCreate bool + AutoIdentity string + Constraints []Constraint + EmbeddedCollections []Relationship + ExportedFields []string + Fields []Field + IdentityField string + IdentityFieldFormatter FieldFormatterFunc + IdentityFieldIndex int + IdentityFieldType Type + IdentityFieldValidator FieldValidatorFunc + IndexCompoundFieldJoiner string + IndexCompoundFields []string + IndexName string + Name string + PreSaveValidator CollectionValidatorFunc + SkipIndexPersistence bool + SourceURI string + TimeToLiveField string + TotalRecords int64 + TotalRecordsExact bool + View bool + ViewKeywords string + ViewQuery interface{} + func NewCollection(name string, fields ...Field) *Collection + func (self *Collection) AddFields(fields ...Field) *Collection + func (self *Collection) ApplyDefinition(definition *Collection) error + func (self *Collection) Check() error + func (self *Collection) ConvertValue(name string, value interface{}) interface{} + func (self *Collection) Diff(actual *Collection) []*SchemaDelta + func (self *Collection) EmptyRecord() *Record + func (self *Collection) FillDefaults(record *Record) + func (self *Collection) GetAggregatorName() string + func (self *Collection) GetAllConstraints() (constraints []Constraint) + func (self *Collection) GetField(name string) (Field, bool) + func (self *Collection) GetFieldByIndex(index int) (Field, bool) + func (self *Collection) GetFirstNonIdentityKeyField() (Field, bool) + func (self *Collection) GetIdentityFieldName() string + func (self *Collection) GetIndexName() string + func (self *Collection) GetRelatedCollection(name string) (*Collection, error) + func (self *Collection) HasRecordType() bool + func (self *Collection) IsExpired(record *Record) bool + func (self *Collection) IsIdentityField(name string) bool + func (self *Collection) IsKeyField(name string) bool + func (self *Collection) KeyCount() int + func (self *Collection) KeyFieldNames() (names []string) + func (self *Collection) KeyFields() []Field + func (self *Collection) MakeRecord(in interface{}, ops ...FieldOperation) (*Record, error) + func (self *Collection) MapFromRecord(record *Record, fields ...string) (map[string]interface{}, error) + func (self *Collection) SetBackend(backend Backend) + func (self *Collection) SetIdentity(name string, idtype Type, formatter FieldFormatterFunc, ...) *Collection + func (self *Collection) SetRecordType(in interface{}) *Collection + func (self *Collection) StructToRecord(in interface{}) (*Record, error) + func (self *Collection) TTL(record *Record) time.Duration + func (self *Collection) ValidateRecord(record *Record, op FieldOperation) error + func (self *Collection) ValueForField(name string, value interface{}, op FieldOperation) (interface{}, error) + type CollectionAction int + const SchemaCreate + const SchemaEnforce + const SchemaExpand + const SchemaRemove + const SchemaVerify + type CollectionValidatorFunc func(*Record) error + type ConnectionString struct + Options map[string]interface{} + URI *url.URL + func MakeConnectionString(scheme string, host string, dataset string, options map[string]interface{}) (ConnectionString, error) + func MustParseConnectionString(conn string) ConnectionString + func ParseConnectionString(conn string) (ConnectionString, error) + func (self *ConnectionString) Backend() string + func (self *ConnectionString) ClearOpt(key string) + func (self *ConnectionString) Credentials() (string, string, bool) + func (self *ConnectionString) Dataset() string + func (self *ConnectionString) HasOpt(key string) bool + func (self *ConnectionString) Host(defaults ...string) string + func (self *ConnectionString) LoadCredentialsFromNetrc(filename string) error + func (self *ConnectionString) Opt(key string) typeutil.Variant + func (self *ConnectionString) OptBool(key string, fallback bool) bool + func (self *ConnectionString) OptDuration(key string, fallback time.Duration) time.Duration + func (self *ConnectionString) OptFloat(key string, fallback float64) float64 + func (self *ConnectionString) OptInt(key string, fallback int64) int64 + func (self *ConnectionString) OptString(key string, fallback string) string + func (self *ConnectionString) OptTime(key string, fallback time.Time) time.Time + func (self *ConnectionString) Protocol(defaults ...string) string + func (self *ConnectionString) Scheme() (string, string) + func (self *ConnectionString) SetCredentials(username string, password string) + func (self *ConnectionString) String() string + type Constraint struct + Collection string + Field interface{} + Into string + NoEmbed bool + On interface{} + Options string + func (self Constraint) Equal(other *Constraint) bool + func (self Constraint) Validate() error + type DeltaIssue int + const CollectionKeyNameIssue + const CollectionKeyTypeIssue + const CollectionNameIssue + const FieldLengthIssue + const FieldMissingIssue + const FieldNameIssue + const FieldPropertyIssue + const FieldTypeIssue + const UnknownIssue + type DeltaType string + const CollectionDelta + const FieldDelta + type EncoderFunc func([]byte) (string, error) + type Field struct + BelongsTo interface{} + DefaultValue interface{} + Description string + Formatter FieldFormatterFunc + FormatterConfig map[string]interface{} + Identity bool + Index int + Key bool + KeyType Type + Length int + Name string + NativeType string + NotUserEditable bool + Precision int + ReadOnly bool + Required bool + Subtype Type + Type Type + Unique bool + UniqueGroup string + ValidateOnPopulate bool + Validator FieldValidatorFunc + ValidatorConfig map[string]interface{} + func (self *Field) BelongsToConstraint() *Constraint + func (self *Field) ConvertValue(in interface{}) (interface{}, error) + func (self *Field) Diff(other *Field) []*SchemaDelta + func (self *Field) Format(value interface{}, op FieldOperation) (interface{}, error) + func (self *Field) GetDefaultValue() interface{} + func (self *Field) GetTypeInstance() interface{} + func (self *Field) MarshalJSON() ([]byte, error) + func (self *Field) UnmarshalJSON(b []byte) error + func (self *Field) Validate(value interface{}) error + type FieldFormatterFunc func(interface{}, FieldOperation) (interface{}, error) + func ChangeCase(cases ...string) FieldFormatterFunc + func DeriveFromFields(format string, fields ...string) FieldFormatterFunc + func FormatAll(formatters ...FieldFormatterFunc) FieldFormatterFunc + func FormatterFromMap(in map[string]interface{}) (FieldFormatterFunc, error) + func GenerateEncodedUUID(encoder EncoderFunc) FieldFormatterFunc + func GetFormatter(name string, args interface{}) (FieldFormatterFunc, error) + func IfUnset(onlyIf FieldFormatterFunc) FieldFormatterFunc + func NowPlusDuration(duration time.Duration) FieldFormatterFunc + func Replace(pairs []interface{}) FieldFormatterFunc + type FieldOperation int + const PersistOperation + const RetrieveOperation + type FieldValidatorFunc func(interface{}) error + func GetValidator(name string, args interface{}) (FieldValidatorFunc, error) + func ValidateAll(validators ...FieldValidatorFunc) FieldValidatorFunc + func ValidateIsOneOf(choices ...interface{}) FieldValidatorFunc + func ValidateMatchAll(patterns ...string) FieldValidatorFunc + func ValidateMatchAny(patterns ...string) FieldValidatorFunc + func ValidatorFromMap(in map[string]interface{}) (FieldValidatorFunc, error) + type Migratable interface + Migrate func() error + type Model interface + type Record struct + CollectionName string + Data []byte + Error error + Fields map[string]interface{} + ID interface{} + Operation string + Optional bool + func NewRecord(id interface{}, data ...map[string]interface{}) *Record + func NewRecordErr(id interface{}, err error) *Record + func (self *Record) Append(key string, value ...interface{}) *Record + func (self *Record) AppendNested(key string, value ...interface{}) *Record + func (self *Record) Copy(other *Record, schema ...*Collection) error + func (self *Record) Get(key string, fallback ...interface{}) interface{} + func (self *Record) GetNested(key string, fallback ...interface{}) interface{} + func (self *Record) GetString(key string, fallback ...string) string + func (self *Record) Keys(collection *Collection) []interface{} + func (self *Record) Map(fields ...string) map[string]interface{} + func (self *Record) OnlyFields(fields []string) *Record + func (self *Record) Populate(into interface{}, collection *Collection) error + func (self *Record) Set(key string, value interface{}) *Record + func (self *Record) SetData(data []byte) *Record + func (self *Record) SetFields(values map[string]interface{}) *Record + func (self *Record) SetKeys(collection *Collection, op FieldOperation, keys ...interface{}) error + func (self *Record) SetNested(key string, value interface{}) *Record + func (self *Record) String() string + type RecordSet struct + KnownSize bool + Options map[string]interface{} + Page int + Records []*Record + RecordsPerPage int + ResultCount int64 + TotalPages int + func NewRecordSet(records ...*Record) *RecordSet + func (self *RecordSet) Append(other *RecordSet) *RecordSet + func (self *RecordSet) GetRecord(index int) (*Record, bool) + func (self *RecordSet) GetRecordByID(id interface{}) (*Record, bool) + func (self *RecordSet) IsEmpty() bool + func (self *RecordSet) Pluck(field string, fallback ...interface{}) []interface{} + func (self *RecordSet) PopulateFromRecords(into interface{}, schema *Collection) error + func (self *RecordSet) Push(record *Record) *RecordSet + type Relationship struct + Collection *Collection + CollectionName string + Fields []string + Force bool + Keys interface{} + func (self *Relationship) RelatedCollectionName() string + type SchemaDelta struct + Actual interface{} + Collection string + Desired interface{} + Issue DeltaIssue + Message string + Name string + Parameter string + ReferenceField *Field + Type DeltaType + func (self SchemaDelta) DesiredField(from Field) *Field + func (self SchemaDelta) String() string + type Type string + var DefaultIdentityFieldType Type = IntType + func ParseFieldType(in string) Type + func (self Type) String() string v4.0.0-alpha.1 Sep 6, 2022 Other modules containing this package github.com/PerformLine/pivot/v3