Documentation ¶
Index ¶
- func CreateWithHooks(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel) (models.IModel, error)
- func CreateWithHooksUser(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel) (models.IModel, error)
- type ICreateOneMapper
- type IDeleteMany
- type IDeleteOneWithID
- type IGetAllMapper
- type IGetOneWithIDMapper
- type IPatchOneWithIDMapper
- type IUpdateManyMapper
- type IUpdateOneWithIDMapper
- type OwnershipMapper
- func (mapper *OwnershipMapper) CreateOne(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel) (models.IModel, error)
- func (mapper *OwnershipMapper) DeleteMany(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObjs []models.IModel) ([]models.IModel, error)
- func (mapper *OwnershipMapper) DeleteOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, id datatypes.UUID) (models.IModel, error)
- func (mapper *OwnershipMapper) GetOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, id datatypes.UUID) (models.IModel, models.UserRole, error)
- func (mapper *OwnershipMapper) PatchOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, jsonPatch []byte, ...) (models.IModel, error)
- func (mapper *OwnershipMapper) ReadAll(db *gorm.DB, oid *datatypes.UUID, typeString string, ...) ([]models.IModel, []models.UserRole, error)
- func (mapper *OwnershipMapper) UpdateMany(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObjs []models.IModel) ([]models.IModel, error)
- func (mapper *OwnershipMapper) UpdateOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel, ...) (models.IModel, error)
- type UserMapper
- func (mapper *UserMapper) CreateOne(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel) (models.IModel, error)
- func (mapper *UserMapper) DeleteOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, id datatypes.UUID) (models.IModel, error)
- func (mapper *UserMapper) GetOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, id datatypes.UUID) (models.IModel, models.UserRole, error)
- func (mapper *UserMapper) UpdateOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel, ...) (models.IModel, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ICreateOneMapper ¶
type ICreateOneMapper interface {
CreateOne(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel) (models.IModel, error)
}
ICreateOneMapper has a create one interface
type IDeleteMany ¶
type IDeleteMany interface {
DeleteMany(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObjs []models.IModel) ([]models.IModel, error)
}
IDeleteMany delete many records
type IDeleteOneWithID ¶
type IDeleteOneWithID interface {
DeleteOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, id datatypes.UUID) (models.IModel, error)
}
IDeleteOneWithID delete a record with the ID
type IGetAllMapper ¶
type IGetAllMapper interface {
ReadAll(db *gorm.DB, oid *datatypes.UUID, typeString string, options map[string]interface{}) ([]models.IModel, []models.UserRole, error)
}
IGetAllMapper gets all record
type IGetOneWithIDMapper ¶
type IGetOneWithIDMapper interface { GetOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, id datatypes.UUID) (models.IModel, models.UserRole, error) // contains filtered or unexported methods }
IGetOneWithIDMapper gets a record with ID
type IPatchOneWithIDMapper ¶
type IPatchOneWithIDMapper interface {
PatchOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, jsonPatch []byte, id datatypes.UUID) (models.IModel, error)
}
IPatchOneWithIDMapper patch a record with the ID
type IUpdateManyMapper ¶
type IUpdateManyMapper interface {
UpdateMany(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObjs []models.IModel) ([]models.IModel, error)
}
IUpdateManyMapper updates many records
type IUpdateOneWithIDMapper ¶
type IUpdateOneWithIDMapper interface {
UpdateOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, modelobj models.IModel, id datatypes.UUID) (models.IModel, error)
}
IUpdateOneWithIDMapper updates a record with the ID
type OwnershipMapper ¶ added in v0.1.18
type OwnershipMapper struct { }
OwnershipMapper is a basic CRUD manager
func SharedOwnershipMapper ¶ added in v0.1.18
func SharedOwnershipMapper() *OwnershipMapper
SharedOwnershipMapper creats a singleton of Crud object
func (*OwnershipMapper) CreateOne ¶ added in v0.1.18
func (mapper *OwnershipMapper) CreateOne(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel) (models.IModel, error)
CreateOne creates an instance of this model based on json and store it in db
func (*OwnershipMapper) DeleteMany ¶ added in v0.1.18
func (mapper *OwnershipMapper) DeleteMany(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObjs []models.IModel) ([]models.IModel, error)
DeleteMany deletes multiple models
func (*OwnershipMapper) DeleteOneWithID ¶ added in v0.1.18
func (mapper *OwnershipMapper) DeleteOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, id datatypes.UUID) (models.IModel, error)
DeleteOneWithID delete the model TODO: delete the groups associated with this record?
func (*OwnershipMapper) GetOneWithID ¶ added in v0.1.18
func (mapper *OwnershipMapper) GetOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, id datatypes.UUID) (models.IModel, models.UserRole, error)
GetOneWithID get one model object based on its type and its id string
func (*OwnershipMapper) PatchOneWithID ¶ added in v0.1.18
func (mapper *OwnershipMapper) PatchOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, jsonPatch []byte, id datatypes.UUID) (models.IModel, error)
PatchOneWithID updates model based on this json
func (*OwnershipMapper) ReadAll ¶ added in v0.1.18
func (mapper *OwnershipMapper) ReadAll(db *gorm.DB, oid *datatypes.UUID, typeString string, options map[string]interface{}) ([]models.IModel, []models.UserRole, error)
ReadAll obtains a slice of models.DomainModel options can be string "offset" and "limit", both of type int This is very Javascript-esque. I would have liked Python's optional parameter more. Alas, no such feature in Go. https://stackoverflow.com/questions/2032149/optional-parameters-in-go How does Gorm do the following? Might want to check out its source code. Cancel offset condition with -1
db.Offset(10).Find(&users1).Offset(-1).Find(&users2)
type UserMapper ¶
type UserMapper struct { }
UserMapper is a User CRUD manager
func SharedUserMapper ¶
func SharedUserMapper() *UserMapper
SharedUserMapper creats a singleton of Crud object
func (*UserMapper) CreateOne ¶
func (mapper *UserMapper) CreateOne(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel) (models.IModel, error)
CreateOne creates an user model based on json and store it in db Also creates a ownership with admin access
func (*UserMapper) DeleteOneWithID ¶
func (mapper *UserMapper) DeleteOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, id datatypes.UUID) (models.IModel, error)
DeleteOneWithID deletes the user with the ID