Documentation ¶
Index ¶
- Constants
- Variables
- func AssociateManyToMany[L Models, R Models](ctx context.Context, db *gorm.DB, associations *ManyToManyAssociations, ...) error
- func Delete[M Models](ctx context.Context, db *gorm.DB, ids []string) ([]M, error)
- func DeleteAddressGormModels(ctx context.Context, tx *gorm.DB, ids []string) error
- func DeleteCommentGormModels(ctx context.Context, tx *gorm.DB, ids []string) error
- func DeleteCompanyGormModels(ctx context.Context, tx *gorm.DB, ids []string) error
- func DeleteProfileGormModels(ctx context.Context, tx *gorm.DB, ids []string) error
- func DeleteUserGormModels(ctx context.Context, tx *gorm.DB, ids []string) error
- func DissociateManyToMany[L Models, R Models](ctx context.Context, db *gorm.DB, associations *ManyToManyAssociations, ...) error
- func GetByIds[M Models](ctx context.Context, db *gorm.DB, ids []string, ...) ([]M, error)
- func List[M Models](ctx context.Context, db *gorm.DB, limit, offset int, orderBy string, ...) ([]M, error)
- func ReplaceManyToMany[L Models, R Models](ctx context.Context, db *gorm.DB, associations *ManyToManyAssociations, ...) error
- func ToModels[P Protos, M Models](protos interface{}) ([]M, error)
- func ToProtos[P Protos, M Models](models interface{}) ([]P, error)
- func Upsert[P Protos, M Models](ctx context.Context, db *gorm.DB, protos interface{}) ([]M, error)
- type Address
- func (*Address) Descriptor() ([]byte, []int)deprecated
- func (x *Address) GetCompanyBlob() *Company
- func (x *Address) GetCreatedAt() *timestamppb.Timestamp
- func (x *Address) GetId() string
- func (x *Address) GetName() string
- func (p *Address) GetProtoId() *string
- func (x *Address) GetUpdatedAt() *timestamppb.Timestamp
- func (x *Address) GetUser() *User
- func (x *Address) GetUserId() string
- func (msg *Address) MarshalJSON() ([]byte, error)
- func (*Address) ProtoMessage()
- func (x *Address) ProtoReflect() protoreflect.Message
- func (x *Address) Reset()
- func (p *Address) SetProtoId(id string)
- func (x *Address) String() string
- func (p *Address) ToModel() (theModel *AddressGormModel, err error)
- func (msg *Address) UnmarshalJSON(b []byte) error
- type AddressGormModel
- type AddressGormModels
- type AddressProtos
- func (p *AddressProtos) GetByIds(ctx context.Context, tx *gorm.DB, ids []string, preloads ...string) (err error)
- func (p *AddressProtos) List(ctx context.Context, tx *gorm.DB, limit, offset int, order interface{}, ...) (err error)
- func (p AddressProtos) ToModels() (models AddressGormModels, err error)
- func (p *AddressProtos) Upsert(ctx context.Context, tx *gorm.DB) (models AddressGormModels, err error)
- type Comment
- func (*Comment) Descriptor() ([]byte, []int)deprecated
- func (x *Comment) GetCreatedAt() *timestamppb.Timestamp
- func (x *Comment) GetId() string
- func (x *Comment) GetName() string
- func (p *Comment) GetProtoId() *string
- func (x *Comment) GetUpdatedAt() *timestamppb.Timestamp
- func (x *Comment) GetUser() *User
- func (x *Comment) GetUserId() string
- func (msg *Comment) MarshalJSON() ([]byte, error)
- func (*Comment) ProtoMessage()
- func (x *Comment) ProtoReflect() protoreflect.Message
- func (x *Comment) Reset()
- func (p *Comment) SetProtoId(id string)
- func (x *Comment) String() string
- func (p *Comment) ToModel() (theModel *CommentGormModel, err error)
- func (msg *Comment) UnmarshalJSON(b []byte) error
- type CommentGormModel
- type CommentGormModels
- type CommentProtos
- func (p *CommentProtos) GetByIds(ctx context.Context, tx *gorm.DB, ids []string, preloads ...string) (err error)
- func (p *CommentProtos) List(ctx context.Context, tx *gorm.DB, limit, offset int, order interface{}, ...) (err error)
- func (p CommentProtos) ToModels() (models CommentGormModels, err error)
- func (p *CommentProtos) Upsert(ctx context.Context, tx *gorm.DB) (models CommentGormModels, err error)
- type Company
- func (*Company) Descriptor() ([]byte, []int)deprecated
- func (x *Company) GetCreatedAt() *timestamppb.Timestamp
- func (x *Company) GetId() string
- func (x *Company) GetName() string
- func (p *Company) GetProtoId() *string
- func (x *Company) GetUpdatedAt() *timestamppb.Timestamp
- func (msg *Company) MarshalJSON() ([]byte, error)
- func (*Company) ProtoMessage()
- func (x *Company) ProtoReflect() protoreflect.Message
- func (x *Company) Reset()
- func (p *Company) SetProtoId(id string)
- func (x *Company) String() string
- func (p *Company) ToModel() (theModel *CompanyGormModel, err error)
- func (msg *Company) UnmarshalJSON(b []byte) error
- type CompanyGormModel
- type CompanyGormModels
- type CompanyProtos
- func (p *CompanyProtos) GetByIds(ctx context.Context, tx *gorm.DB, ids []string, preloads ...string) (err error)
- func (p *CompanyProtos) List(ctx context.Context, tx *gorm.DB, limit, offset int, order interface{}, ...) (err error)
- func (p CompanyProtos) ToModels() (models CompanyGormModels, err error)
- func (p *CompanyProtos) Upsert(ctx context.Context, tx *gorm.DB) (models CompanyGormModels, err error)
- type EnumOne
- type ManyToManyAssociations
- type Model
- type Models
- type Profile
- func (*Profile) Descriptor() ([]byte, []int)deprecated
- func (x *Profile) GetCreatedAt() *timestamppb.Timestamp
- func (x *Profile) GetId() string
- func (x *Profile) GetName() string
- func (p *Profile) GetProtoId() *string
- func (x *Profile) GetUpdatedAt() *timestamppb.Timestamp
- func (msg *Profile) MarshalJSON() ([]byte, error)
- func (*Profile) ProtoMessage()
- func (x *Profile) ProtoReflect() protoreflect.Message
- func (x *Profile) Reset()
- func (p *Profile) SetProtoId(id string)
- func (x *Profile) String() string
- func (p *Profile) ToModel() (theModel *ProfileGormModel, err error)
- func (msg *Profile) UnmarshalJSON(b []byte) error
- type ProfileGormModel
- type ProfileGormModels
- type ProfileProtos
- func (p *ProfileProtos) GetByIds(ctx context.Context, tx *gorm.DB, ids []string, preloads ...string) (err error)
- func (p *ProfileProtos) List(ctx context.Context, tx *gorm.DB, limit, offset int, order interface{}, ...) (err error)
- func (p ProfileProtos) ToModels() (models ProfileGormModels, err error)
- func (p *ProfileProtos) Upsert(ctx context.Context, tx *gorm.DB) (models ProfileGormModels, err error)
- type Proto
- type Protos
- type User
- func (*User) Descriptor() ([]byte, []int)deprecated
- func (x *User) GetABool() bool
- func (x *User) GetABytes() []byte
- func (x *User) GetADouble() float64
- func (x *User) GetAFloat() float32
- func (x *User) GetAString() string
- func (x *User) GetAStructpb() *structpb.Struct
- func (x *User) GetAddress() *Address
- func (x *User) GetAnInt32() int32
- func (x *User) GetAnInt64() int64
- func (x *User) GetAnUnexpectedId() string
- func (x *User) GetBools() []bool
- func (x *User) GetBytess() [][]byte
- func (x *User) GetComments() []*Comment
- func (x *User) GetCompany() *Company
- func (x *User) GetCompanyId() string
- func (x *User) GetCompanyThree() *Company
- func (x *User) GetCompanyTwo() *Company
- func (x *User) GetCompanyTwoId() string
- func (x *User) GetCreatedAt() string
- func (x *User) GetDate() string
- func (x *User) GetDoubles() []float64
- func (x *User) GetFloats() []float32
- func (x *User) GetId() string
- func (x *User) GetInt32S() []int32
- func (x *User) GetInt64S() []int64
- func (x *User) GetIntEnum() EnumOne
- func (x *User) GetIntEnumList() []EnumOne
- func (x *User) GetOptionalDate() string
- func (x *User) GetOptionalScalarField() string
- func (x *User) GetProfiles() []*Profile
- func (p *User) GetProtoId() *string
- func (x *User) GetSomeTimestamp() *timestamppb.Timestamp
- func (x *User) GetStringEnum() EnumOne
- func (x *User) GetStringEnumList() []EnumOne
- func (x *User) GetStrings() []string
- func (x *User) GetUpdatedAt() *timestamppb.Timestamp
- func (msg *User) MarshalJSON() ([]byte, error)
- func (*User) ProtoMessage()
- func (x *User) ProtoReflect() protoreflect.Message
- func (x *User) Reset()
- func (p *User) SetProtoId(id string)
- func (x *User) String() string
- func (p *User) ToModel() (theModel *UserGormModel, err error)
- func (msg *User) UnmarshalJSON(b []byte) error
- type UserGormModel
- type UserGormModels
- type UserProtos
- func (p *UserProtos) GetByIds(ctx context.Context, tx *gorm.DB, ids []string, preloads ...string) (err error)
- func (p *UserProtos) List(ctx context.Context, tx *gorm.DB, limit, offset int, order interface{}, ...) (err error)
- func (p UserProtos) ToModels() (models UserGormModels, err error)
- func (p *UserProtos) Upsert(ctx context.Context, tx *gorm.DB) (models UserGormModels, err error)
Constants ¶
const TimestampFormat = "2006-01-02T15:04:05.999999Z07:00"
cockroachdb doesn't support nanosecond timestamp columns so use microsecond instead
Variables ¶
var ( EnumOne_name = map[int32]string{ 0: "Default", 1: "One", 2: "Two", 3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine", } EnumOne_value = map[string]int32{ "Default": 0, "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5, "Six": 6, "Seven": 7, "Eight": 8, "Nine": 9, } )
Enum value maps for EnumOne.
var File_postgres_example_proto protoreflect.FileDescriptor
Functions ¶
func AssociateManyToMany ¶ added in v1.0.1
func Delete ¶ added in v1.0.1
Delete is a generic function that will delete any of the generated protos. A function may be provided to be executed during the transaction. The function is executed after the delete. If the function returns an error, the transaction will be rolled back.
func DeleteAddressGormModels ¶
func DeleteCommentGormModels ¶
func DeleteCompanyGormModels ¶
func DeleteProfileGormModels ¶
func DeleteUserGormModels ¶
func DissociateManyToMany ¶ added in v1.0.1
func GetByIds ¶ added in v1.0.1
func GetByIds[M Models](ctx context.Context, db *gorm.DB, ids []string, preloads map[string][]interface{}) ([]M, error)
GetByIds gets the given model type by id
func List ¶ added in v1.0.1
func List[M Models](ctx context.Context, db *gorm.DB, limit, offset int, orderBy string, preloads map[string][]interface{}) ([]M, error)
List lists the given model type
func ReplaceManyToMany ¶ added in v1.0.3
func ToModels ¶ added in v1.0.1
ToModels converts an array of protos to an array of gorm db models by calling the proto's ToModel method
func ToProtos ¶ added in v1.0.1
ToProtos converts an array of models into an array of protos by calling the model's ToProto method
func Upsert ¶ added in v1.0.1
Upsert is a generic function that will upsert any of the generated protos, returning the upserted models. Upsert excludes all associations, and uses an on conflict clause to handle upsert. A function may be provided to be executed during the transaction. The function is executed after the upsert. If the function returns an error, the transaction will be rolled back.
Types ¶
type Address ¶
type Address struct { // @gotags: fake:"skip" Id *string `protobuf:"bytes,1,opt,name=id,proto3,oneof" json:"id,omitempty" fake:"skip"` // @gotags: fake:"skip" CreatedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty" fake:"skip"` // @gotags: fake:"{name}" Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty" fake:"{name}"` // @gotags: fake:"skip" UserId *string `protobuf:"bytes,5,opt,name=user_id,json=userId,proto3,oneof" json:"user_id,omitempty" fake:"skip"` // @gotags: fake:"skip" User *User `protobuf:"bytes,6,opt,name=user,proto3" json:"user,omitempty" fake:"skip"` // @gotags: fake:"skip" CompanyBlob *Company `protobuf:"bytes,7,opt,name=companyBlob,proto3" json:"companyBlob,omitempty" fake:"skip"` // contains filtered or unexported fields }
func (*Address) Descriptor
deprecated
func (*Address) GetCompanyBlob ¶ added in v0.1.32
func (*Address) GetCreatedAt ¶
func (x *Address) GetCreatedAt() *timestamppb.Timestamp
func (*Address) GetProtoId ¶ added in v1.0.1
func (*Address) GetUpdatedAt ¶
func (x *Address) GetUpdatedAt() *timestamppb.Timestamp
func (*Address) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Address) ProtoMessage ¶
func (*Address) ProtoMessage()
func (*Address) ProtoReflect ¶
func (x *Address) ProtoReflect() protoreflect.Message
func (*Address) SetProtoId ¶ added in v1.0.1
func (*Address) ToModel ¶
func (p *Address) ToModel() (theModel *AddressGormModel, err error)
func (*Address) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type AddressGormModel ¶
type AddressGormModel struct { // @gotags: fake:"skip" Id *string `gorm:"type:uuid;primaryKey;default:uuid_generate_v4();" json:"id" fake:"skip"` // @gotags: fake:"skip" CreatedAt *time.Time `gorm:"type:timestamp;" json:"createdAt" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *time.Time `gorm:"type:timestamp;" json:"updatedAt" fake:"skip"` // @gotags: fake:"{name}" Name string `json:"name" fake:"{name}"` // @gotags: fake:"skip" UserId *string `json:"userId" fake:"skip"` // @gotags: fake:"skip" User *UserGormModel `gorm:"foreignKey:UserId;references:Id;constraint:OnDelete:CASCADE;" json:"user" fake:"skip"` // @gotags: fake:"skip" CompanyBlob gorm_jsonb.JSONB `gorm:"type:jsonb" json:"companyBlob" fake:"skip"` }
func (*AddressGormModel) GetModelId ¶ added in v1.0.1
func (m *AddressGormModel) GetModelId() *string
func (*AddressGormModel) New ¶ added in v1.0.1
func (m *AddressGormModel) New() interface{}
func (*AddressGormModel) SetModelId ¶ added in v1.0.1
func (m *AddressGormModel) SetModelId(id string)
func (*AddressGormModel) TableName ¶
func (m *AddressGormModel) TableName() string
func (*AddressGormModel) ToProto ¶
func (m *AddressGormModel) ToProto() (theProto *Address, err error)
type AddressGormModels ¶
type AddressGormModels []*AddressGormModel
func (AddressGormModels) GetByModelIds ¶
func (AddressGormModels) ToProtos ¶
func (m AddressGormModels) ToProtos() (protos AddressProtos, err error)
type AddressProtos ¶
type AddressProtos []*Address
func (AddressProtos) ToModels ¶
func (p AddressProtos) ToModels() (models AddressGormModels, err error)
func (*AddressProtos) Upsert ¶
func (p *AddressProtos) Upsert(ctx context.Context, tx *gorm.DB) (models AddressGormModels, err error)
Upsert creates the protos using an on conflict clause to do updates. This function does not update *any* associations use gorm's association mode functions to update associations as you see fit after calling upsert. See https://gorm.io/docs/associations.html#Replace-Associations
type Comment ¶
type Comment struct { // @gotags: fake:"skip" Id *string `protobuf:"bytes,1,opt,name=id,proto3,oneof" json:"id,omitempty" fake:"skip"` // @gotags: fake:"skip" CreatedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty" fake:"skip"` // @gotags: fake:"{name}" Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty" fake:"{name}"` // @gotags: fake:"skip" UserId *string `protobuf:"bytes,5,opt,name=userId,proto3,oneof" json:"userId,omitempty" fake:"skip"` // @gotags: fake:"skip" User *User `protobuf:"bytes,6,opt,name=user,proto3" json:"user,omitempty" fake:"skip"` // contains filtered or unexported fields }
func (*Comment) Descriptor
deprecated
func (*Comment) GetCreatedAt ¶
func (x *Comment) GetCreatedAt() *timestamppb.Timestamp
func (*Comment) GetProtoId ¶ added in v1.0.1
func (*Comment) GetUpdatedAt ¶
func (x *Comment) GetUpdatedAt() *timestamppb.Timestamp
func (*Comment) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Comment) ProtoMessage ¶
func (*Comment) ProtoMessage()
func (*Comment) ProtoReflect ¶
func (x *Comment) ProtoReflect() protoreflect.Message
func (*Comment) SetProtoId ¶ added in v1.0.1
func (*Comment) ToModel ¶
func (p *Comment) ToModel() (theModel *CommentGormModel, err error)
func (*Comment) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type CommentGormModel ¶
type CommentGormModel struct { // @gotags: fake:"skip" Id *string `gorm:"type:uuid;primaryKey;default:uuid_generate_v4();" json:"id" fake:"skip"` // @gotags: fake:"skip" CreatedAt *time.Time `gorm:"type:timestamp;" json:"createdAt" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *time.Time `gorm:"type:timestamp;" json:"updatedAt" fake:"skip"` // @gotags: fake:"{name}" Name string `json:"name" fake:"{name}"` // @gotags: fake:"skip" UserId *string `json:"userId" fake:"skip"` // @gotags: fake:"skip" User *UserGormModel `gorm:"foreignKey:UserId;references:Id;constraint:OnDelete:CASCADE;" json:"user" fake:"skip"` }
func (*CommentGormModel) GetModelId ¶ added in v1.0.1
func (m *CommentGormModel) GetModelId() *string
func (*CommentGormModel) New ¶ added in v1.0.1
func (m *CommentGormModel) New() interface{}
func (*CommentGormModel) SetModelId ¶ added in v1.0.1
func (m *CommentGormModel) SetModelId(id string)
func (*CommentGormModel) TableName ¶
func (m *CommentGormModel) TableName() string
func (*CommentGormModel) ToProto ¶
func (m *CommentGormModel) ToProto() (theProto *Comment, err error)
type CommentGormModels ¶
type CommentGormModels []*CommentGormModel
func (CommentGormModels) GetByModelIds ¶
func (CommentGormModels) ToProtos ¶
func (m CommentGormModels) ToProtos() (protos CommentProtos, err error)
type CommentProtos ¶
type CommentProtos []*Comment
func (CommentProtos) ToModels ¶
func (p CommentProtos) ToModels() (models CommentGormModels, err error)
func (*CommentProtos) Upsert ¶
func (p *CommentProtos) Upsert(ctx context.Context, tx *gorm.DB) (models CommentGormModels, err error)
Upsert creates the protos using an on conflict clause to do updates. This function does not update *any* associations use gorm's association mode functions to update associations as you see fit after calling upsert. See https://gorm.io/docs/associations.html#Replace-Associations
type Company ¶
type Company struct { // @gotags: fake:"skip" Id *string `protobuf:"bytes,1,opt,name=id,proto3,oneof" json:"id,omitempty" fake:"skip"` // @gotags: fake:"skip" CreatedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty" fake:"skip"` // @gotags: fake:"{name}" Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty" fake:"{name}"` // contains filtered or unexported fields }
func (*Company) Descriptor
deprecated
func (*Company) GetCreatedAt ¶
func (x *Company) GetCreatedAt() *timestamppb.Timestamp
func (*Company) GetProtoId ¶ added in v1.0.1
func (*Company) GetUpdatedAt ¶
func (x *Company) GetUpdatedAt() *timestamppb.Timestamp
func (*Company) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Company) ProtoMessage ¶
func (*Company) ProtoMessage()
func (*Company) ProtoReflect ¶
func (x *Company) ProtoReflect() protoreflect.Message
func (*Company) SetProtoId ¶ added in v1.0.1
func (*Company) ToModel ¶
func (p *Company) ToModel() (theModel *CompanyGormModel, err error)
func (*Company) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type CompanyGormModel ¶
type CompanyGormModel struct { // @gotags: fake:"skip" Id *string `gorm:"type:uuid;primaryKey;default:uuid_generate_v4();" json:"id" fake:"skip"` // @gotags: fake:"skip" CreatedAt *time.Time `gorm:"type:timestamp;" json:"createdAt" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *time.Time `gorm:"type:timestamp;" json:"updatedAt" fake:"skip"` // @gotags: fake:"{name}" Name string `json:"name" fake:"{name}"` }
func (*CompanyGormModel) GetModelId ¶ added in v1.0.1
func (m *CompanyGormModel) GetModelId() *string
func (*CompanyGormModel) New ¶ added in v1.0.1
func (m *CompanyGormModel) New() interface{}
func (*CompanyGormModel) SetModelId ¶ added in v1.0.1
func (m *CompanyGormModel) SetModelId(id string)
func (*CompanyGormModel) TableName ¶
func (m *CompanyGormModel) TableName() string
func (*CompanyGormModel) ToProto ¶
func (m *CompanyGormModel) ToProto() (theProto *Company, err error)
type CompanyGormModels ¶
type CompanyGormModels []*CompanyGormModel
func (CompanyGormModels) GetByModelIds ¶
func (CompanyGormModels) ToProtos ¶
func (m CompanyGormModels) ToProtos() (protos CompanyProtos, err error)
type CompanyProtos ¶
type CompanyProtos []*Company
func (CompanyProtos) ToModels ¶
func (p CompanyProtos) ToModels() (models CompanyGormModels, err error)
func (*CompanyProtos) Upsert ¶
func (p *CompanyProtos) Upsert(ctx context.Context, tx *gorm.DB) (models CompanyGormModels, err error)
Upsert creates the protos using an on conflict clause to do updates. This function does not update *any* associations use gorm's association mode functions to update associations as you see fit after calling upsert. See https://gorm.io/docs/associations.html#Replace-Associations
type EnumOne ¶
type EnumOne int32
func (EnumOne) Descriptor ¶
func (EnumOne) Descriptor() protoreflect.EnumDescriptor
func (EnumOne) EnumDescriptor
deprecated
func (EnumOne) Number ¶
func (x EnumOne) Number() protoreflect.EnumNumber
func (EnumOne) Type ¶
func (EnumOne) Type() protoreflect.EnumType
type ManyToManyAssociations ¶ added in v1.0.1
type ManyToManyAssociations struct {
// contains filtered or unexported fields
}
ManyToManyAssociations is a sync map with helper functions. I'm using a sync.map so that it's thread safe, and a struct to allow us to easily define behavior we can use elsewhere
func (*ManyToManyAssociations) AddAssociation ¶ added in v1.0.1
func (m *ManyToManyAssociations) AddAssociation(modelId, associatedId string)
func (*ManyToManyAssociations) Associations ¶ added in v1.0.1
func (m *ManyToManyAssociations) Associations() map[string][]string
type Model ¶ added in v1.0.1
Model[P Protos] is an interface type that defines behavior for the implementer of a given Protos type
func ConvertModelToModelP ¶ added in v1.0.1
ConvertProtoToProtosM converts a single proto to a Proto[M]
func ConvertModelsToModelsP ¶ added in v1.0.1
ConvertProtosToProtosM converts a given slice of protos into an array of the Proto interface type, which can then leverage the interface methods
type Models ¶ added in v1.0.1
type Models interface { *UserGormModel | *CompanyGormModel | *AddressGormModel | *CommentGormModel | *ProfileGormModel GetModelId() *string SetModelId(string) New() interface{} TableName() string // tabler interface for gorm model, gives us access to the table name that gorm will use, see https://gorm.io/docs/conventions.html#TableName }
Models is a union of other types that defines which types may be used in generic functions
type Profile ¶
type Profile struct { // @gotags: fake:"skip" Id *string `protobuf:"bytes,1,opt,name=id,proto3,oneof" json:"id,omitempty" fake:"skip"` // @gotags: fake:"skip" CreatedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty" fake:"skip"` // @gotags: fake:"{name}" Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty" fake:"{name}"` // contains filtered or unexported fields }
func (*Profile) Descriptor
deprecated
func (*Profile) GetCreatedAt ¶
func (x *Profile) GetCreatedAt() *timestamppb.Timestamp
func (*Profile) GetProtoId ¶ added in v1.0.1
func (*Profile) GetUpdatedAt ¶
func (x *Profile) GetUpdatedAt() *timestamppb.Timestamp
func (*Profile) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Profile) ProtoMessage ¶
func (*Profile) ProtoMessage()
func (*Profile) ProtoReflect ¶
func (x *Profile) ProtoReflect() protoreflect.Message
func (*Profile) SetProtoId ¶ added in v1.0.1
func (*Profile) ToModel ¶
func (p *Profile) ToModel() (theModel *ProfileGormModel, err error)
func (*Profile) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type ProfileGormModel ¶
type ProfileGormModel struct { // @gotags: fake:"skip" Id *string `gorm:"type:uuid;primaryKey;default:uuid_generate_v4();" json:"id" fake:"skip"` // @gotags: fake:"skip" CreatedAt *time.Time `gorm:"type:timestamp;" json:"createdAt" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *time.Time `gorm:"type:timestamp;" json:"updatedAt" fake:"skip"` // @gotags: fake:"{name}" Name string `json:"name" fake:"{name}"` }
func (*ProfileGormModel) GetModelId ¶ added in v1.0.1
func (m *ProfileGormModel) GetModelId() *string
func (*ProfileGormModel) New ¶ added in v1.0.1
func (m *ProfileGormModel) New() interface{}
func (*ProfileGormModel) SetModelId ¶ added in v1.0.1
func (m *ProfileGormModel) SetModelId(id string)
func (*ProfileGormModel) TableName ¶
func (m *ProfileGormModel) TableName() string
func (*ProfileGormModel) ToProto ¶
func (m *ProfileGormModel) ToProto() (theProto *Profile, err error)
type ProfileGormModels ¶
type ProfileGormModels []*ProfileGormModel
func (ProfileGormModels) GetByModelIds ¶
func (ProfileGormModels) ToProtos ¶
func (m ProfileGormModels) ToProtos() (protos ProfileProtos, err error)
type ProfileProtos ¶
type ProfileProtos []*Profile
func (ProfileProtos) ToModels ¶
func (p ProfileProtos) ToModels() (models ProfileGormModels, err error)
func (*ProfileProtos) Upsert ¶
func (p *ProfileProtos) Upsert(ctx context.Context, tx *gorm.DB) (models ProfileGormModels, err error)
Upsert creates the protos using an on conflict clause to do updates. This function does not update *any* associations use gorm's association mode functions to update associations as you see fit after calling upsert. See https://gorm.io/docs/associations.html#Replace-Associations
type Proto ¶ added in v1.0.1
Proto[M Models] is an interface type that defines behavior for the implementer of a given Models type
func ConvertProtoToProtosM ¶ added in v1.0.1
ConvertProtoToProtosM converts a single proto to a Proto[M]
func ConvertProtosToProtosM ¶ added in v1.0.1
ConvertProtosToProtosM converts a given slice of protos into an array of the Proto interface type, which can then leverage the interface methods
type Protos ¶ added in v1.0.1
type Protos interface { *User | *Company | *Address | *Comment | *Profile GetProtoId() *string SetProtoId(string) }
Protos is a union of other types that defines which types may be used in generic functions
type User ¶
type User struct { // @gotags: fake:"skip" Id *string `protobuf:"bytes,1,opt,name=id,proto3,oneof" json:"id,omitempty" fake:"skip"` // @gotags: fake:"skip" CreatedAt string `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty" fake:"skip"` // @gotags: fake:"{price:0.00,1000.00}" ADouble float64 `protobuf:"fixed64,4,opt,name=a_double,json=aDouble,proto3" json:"a_double,omitempty" fake:"{price:0.00,1000.00}"` // @gotags: fake:"{price:0.00,1000.00}" AFloat float32 `protobuf:"fixed32,5,opt,name=a_float,json=aFloat,proto3" json:"a_float,omitempty" fake:"{price:0.00,1000.00}"` // @gotags: fake:"{int32}" AnInt32 int32 `protobuf:"varint,6,opt,name=an_int32,json=anInt32,proto3" json:"an_int32,omitempty" fake:"{int32}"` // @gotags: fake:"{number:9223372036854775807}" AnInt64 int64 `protobuf:"varint,7,opt,name=an_int64,json=anInt64,proto3" json:"an_int64,omitempty" fake:"{number:9223372036854775807}"` // @gotags: fake:"{bool}" ABool bool `protobuf:"varint,16,opt,name=a_bool,json=aBool,proto3" json:"a_bool,omitempty" fake:"{bool}"` // @gotags: fake:"{hackerphrase}" AString string `protobuf:"bytes,17,opt,name=a_string,json=aString,proto3" json:"a_string,omitempty" fake:"{hackerphrase}"` // @gotags: fake:"skip" ABytes []byte `protobuf:"bytes,18,opt,name=a_bytes,json=aBytes,proto3" json:"a_bytes,omitempty" fake:"skip"` // @gotags: fake:"{price:0.00,1000.00}" Doubles []float64 `protobuf:"fixed64,19,rep,packed,name=doubles,proto3" json:"doubles,omitempty" fake:"{price:0.00,1000.00}"` // @gotags: fake:"{price:0.00,1000.00}" Floats []float32 `protobuf:"fixed32,20,rep,packed,name=floats,proto3" json:"floats,omitempty" fake:"{price:0.00,1000.00}"` // @gotags: fake:"{int32}" Int32S []int32 `protobuf:"varint,21,rep,packed,name=int32s,proto3" json:"int32s,omitempty" fake:"{int32}"` // @gotags: fake:"{number:9223372036854775807}" Int64S []int64 `protobuf:"varint,22,rep,packed,name=int64s,proto3" json:"int64s,omitempty" fake:"{number:9223372036854775807}"` // @gotags: fake:"{bool}" Bools []bool `protobuf:"varint,31,rep,packed,name=bools,proto3" json:"bools,omitempty" fake:"{bool}"` // @gotags: fake:"{hackerphrase}" Strings []string `protobuf:"bytes,32,rep,name=strings,proto3" json:"strings,omitempty" fake:"{hackerphrase}"` // @gotags: fake:"skip" Bytess [][]byte `protobuf:"bytes,33,rep,name=bytess,proto3" json:"bytess,omitempty" fake:"skip"` // @gotags: fake:"skip" OptionalScalarField *string `` /* 139-byte string literal not displayed */ // @gotags: fake:"skip" AStructpb *structpb.Struct `protobuf:"bytes,35,opt,name=a_structpb,json=aStructpb,proto3" json:"a_structpb,omitempty" fake:"skip"` // @gotags: fake:"skip" CompanyId *string `protobuf:"bytes,36,opt,name=companyId,proto3,oneof" json:"companyId,omitempty" fake:"skip"` // @gotags: fake:"skip" Company *Company `protobuf:"bytes,37,opt,name=company,proto3" json:"company,omitempty" fake:"skip"` // @gotags: fake:"skip" CompanyTwoId *string `protobuf:"bytes,38,opt,name=company_two_id,json=companyTwoId,proto3,oneof" json:"company_two_id,omitempty" fake:"skip"` // @gotags: fake:"skip" CompanyTwo *Company `protobuf:"bytes,39,opt,name=company_two,json=companyTwo,proto3" json:"company_two,omitempty" fake:"skip"` // @gotags: fake:"skip" AnUnexpectedId *string `protobuf:"bytes,40,opt,name=an_unexpected_id,json=anUnexpectedId,proto3,oneof" json:"an_unexpected_id,omitempty" fake:"skip"` // @gotags: fake:"skip" CompanyThree *Company `protobuf:"bytes,41,opt,name=company_three,json=companyThree,proto3" json:"company_three,omitempty" fake:"skip"` // @gotags: fake:"skip" Address *Address `protobuf:"bytes,42,opt,name=address,proto3" json:"address,omitempty" fake:"skip"` // @gotags: fake:"skip" Comments []*Comment `protobuf:"bytes,43,rep,name=comments,proto3" json:"comments,omitempty" fake:"skip"` // @gotags: fake:"skip" Profiles []*Profile `protobuf:"bytes,44,rep,name=profiles,proto3" json:"profiles,omitempty" fake:"skip"` // @gotags: fake:"{number:1,9}" IntEnum EnumOne `` /* 134-byte string literal not displayed */ // @gotags: fake:"{number:1,9}" StringEnum EnumOne `` /* 143-byte string literal not displayed */ // @gotags: fake:"{number:1,9}" IntEnumList []EnumOne `` /* 155-byte string literal not displayed */ // @gotags: fake:"{number:1,9}" StringEnumList []EnumOne `` /* 164-byte string literal not displayed */ // @gotags: fake:"{date:2006-01-02}" Date string `protobuf:"bytes,49,opt,name=date,proto3" json:"date,omitempty" fake:"{date:2006-01-02}"` // @gotags: fake:"{date:2006-01-02}" OptionalDate *string `` /* 129-byte string literal not displayed */ // @gotags: fake:"skip" SomeTimestamp *timestamppb.Timestamp `protobuf:"bytes,51,opt,name=some_timestamp,json=someTimestamp,proto3" json:"some_timestamp,omitempty" fake:"skip"` // contains filtered or unexported fields }
func (*User) Descriptor
deprecated
func (*User) GetADouble ¶
func (*User) GetAString ¶
func (*User) GetAStructpb ¶
func (*User) GetAddress ¶
func (*User) GetAnInt32 ¶
func (*User) GetAnInt64 ¶
func (*User) GetAnUnexpectedId ¶
func (*User) GetComments ¶
func (*User) GetCompany ¶
func (*User) GetCompanyId ¶ added in v1.0.1
func (*User) GetCompanyThree ¶
func (*User) GetCompanyTwo ¶
func (*User) GetCompanyTwoId ¶
func (*User) GetCreatedAt ¶
func (*User) GetDoubles ¶
func (*User) GetIntEnum ¶
func (*User) GetIntEnumList ¶
func (*User) GetOptionalDate ¶ added in v0.1.24
func (*User) GetOptionalScalarField ¶
func (*User) GetProfiles ¶
func (*User) GetProtoId ¶ added in v1.0.1
func (*User) GetSomeTimestamp ¶ added in v1.0.0
func (x *User) GetSomeTimestamp() *timestamppb.Timestamp
func (*User) GetStringEnum ¶
func (*User) GetStringEnumList ¶
func (*User) GetStrings ¶
func (*User) GetUpdatedAt ¶
func (x *User) GetUpdatedAt() *timestamppb.Timestamp
func (*User) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) ProtoReflect ¶
func (x *User) ProtoReflect() protoreflect.Message
func (*User) SetProtoId ¶ added in v1.0.1
func (*User) ToModel ¶
func (p *User) ToModel() (theModel *UserGormModel, err error)
func (*User) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type UserGormModel ¶
type UserGormModel struct { // @gotags: fake:"skip" Id *string `gorm:"type:uuid;primaryKey;default:uuid_generate_v4();" json:"id" fake:"skip"` // @gotags: fake:"skip" CreatedAt *time.Time `gorm:"type:timestamp;" json:"createdAt" fake:"skip"` // @gotags: fake:"skip" UpdatedAt *time.Time `gorm:"type:timestamp;" json:"updatedAt" fake:"skip"` // @gotags: fake:"{price:0.00,1000.00}" ADouble float64 `json:"aDouble" fake:"{price:0.00,1000.00}"` // @gotags: fake:"{price:0.00,1000.00}" AFloat float32 `json:"aFloat" fake:"{price:0.00,1000.00}"` // @gotags: fake:"{int32}" AnInt32 int32 `json:"anInt32" fake:"{int32}"` // @gotags: fake:"{number:9223372036854775807}" AnInt64 int64 `json:"anInt64" fake:"{number:9223372036854775807}"` // @gotags: fake:"{bool}" ABool bool `json:"aBool" fake:"{bool}"` // @gotags: fake:"{hackerphrase}" AString string `json:"aString" fake:"{hackerphrase}"` // @gotags: fake:"skip" ABytes []byte `json:"aBytes" fake:"skip"` // @gotags: fake:"{price:0.00,1000.00}" Doubles pq.Float64Array `gorm:"type:double precision[];" json:"doubles" fake:"{price:0.00,1000.00}"` // @gotags: fake:"{price:0.00,1000.00}" Floats pq.Float32Array `gorm:"type:double precision[];" json:"floats" fake:"{price:0.00,1000.00}"` // @gotags: fake:"{int32}" Int32S pq.Int32Array `gorm:"type:integer[];" json:"int32s" fake:"{int32}"` // @gotags: fake:"{number:9223372036854775807}" Int64S pq.Int64Array `gorm:"type:bigint[];" json:"int64s" fake:"{number:9223372036854775807}"` // @gotags: fake:"{bool}" Bools pq.BoolArray `gorm:"type:boolean[];" json:"bools" fake:"{bool}"` // @gotags: fake:"{hackerphrase}" Strings pq.StringArray `gorm:"type:text[];" json:"strings" fake:"{hackerphrase}"` // @gotags: fake:"skip" Bytess pq.ByteaArray `gorm:"type:bytea[];" json:"bytess" fake:"skip"` // @gotags: fake:"skip" OptionalScalarField *string `json:"optionalScalarField" fake:"skip"` // @gotags: fake:"skip" AStructpb gorm_jsonb.JSONB `gorm:"type:jsonb" json:"aStructpb" fake:"skip"` // @gotags: fake:"skip" CompanyId *string `json:"companyId" fake:"skip"` // @gotags: fake:"skip" Company *CompanyGormModel `gorm:"foreignKey:CompanyId;references:Id;constraint:OnDelete:CASCADE;" json:"company" fake:"skip"` // @gotags: fake:"skip" CompanyTwoId *string `json:"companyTwoId" fake:"skip"` // @gotags: fake:"skip" CompanyTwo *CompanyGormModel `gorm:"foreignKey:CompanyTwoId;references:Id;constraint:OnDelete:CASCADE;" json:"companyTwo" fake:"skip"` // @gotags: fake:"skip" AnUnexpectedId *string `json:"anUnexpectedId" fake:"skip"` // @gotags: fake:"skip" CompanyThree *CompanyGormModel `gorm:"foreignKey:AnUnexpectedId;references:Id;constraint:OnDelete:CASCADE;" json:"companyThree" fake:"skip"` // @gotags: fake:"skip" Address *AddressGormModel `gorm:"foreignKey:UserId;references:Id;constraint:OnDelete:CASCADE;" json:"address" fake:"skip"` // @gotags: fake:"skip" Comments []*CommentGormModel `gorm:"foreignKey:UserId;references:Id;constraint:OnDelete:CASCADE;" json:"comments" fake:"skip"` // @gotags: fake:"skip" Profiles []*ProfileGormModel `` /* 163-byte string literal not displayed */ // @gotags: fake:"{number:1,9}" IntEnum int `json:"intEnum" fake:"{number:1,9}"` // @gotags: fake:"{number:1,9}" StringEnum string `json:"stringEnum" fake:"{number:1,9}"` // @gotags: fake:"{number:1,9}" IntEnumList pq.Int32Array `gorm:"type:smallint[];" json:"intEnumList" fake:"{number:1,9}"` // @gotags: fake:"{number:1,9}" StringEnumList pq.StringArray `gorm:"type:text[];" json:"stringEnumList" fake:"{number:1,9}"` // @gotags: fake:"{date:2006-01-02}" Date *time.Time `json:"date" fake:"{date:2006-01-02}"` // @gotags: fake:"{date:2006-01-02}" OptionalDate *time.Time `json:"optionalDate" fake:"{date:2006-01-02}"` // @gotags: fake:"skip" SomeTimestamp *time.Time `gorm:"type:timestamp;" json:"someTimestamp" fake:"skip"` }
func (*UserGormModel) GetModelId ¶ added in v1.0.1
func (m *UserGormModel) GetModelId() *string
func (*UserGormModel) New ¶ added in v1.0.1
func (m *UserGormModel) New() interface{}
func (*UserGormModel) SetModelId ¶ added in v1.0.1
func (m *UserGormModel) SetModelId(id string)
func (*UserGormModel) TableName ¶
func (m *UserGormModel) TableName() string
func (*UserGormModel) ToProto ¶
func (m *UserGormModel) ToProto() (theProto *User, err error)
type UserGormModels ¶
type UserGormModels []*UserGormModel
func (UserGormModels) GetByModelIds ¶
func (UserGormModels) ToProtos ¶
func (m UserGormModels) ToProtos() (protos UserProtos, err error)
type UserProtos ¶
type UserProtos []*User
func (UserProtos) ToModels ¶
func (p UserProtos) ToModels() (models UserGormModels, err error)
func (*UserProtos) Upsert ¶
func (p *UserProtos) Upsert(ctx context.Context, tx *gorm.DB) (models UserGormModels, err error)
Upsert creates the protos using an on conflict clause to do updates. This function does not update *any* associations use gorm's association mode functions to update associations as you see fit after calling upsert. See https://gorm.io/docs/associations.html#Replace-Associations