datamapper

package
v0.1.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateWithHooks

func CreateWithHooks(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel) (models.IModel, error)

CreateWithHooks handles before and after DB hookpoints for create

func CreateWithHooksUser added in v0.1.18

func CreateWithHooksUser(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel) (models.IModel, error)

CreateWithHooksUser handles before and after DB hookpoints for creating a user

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)

func (*OwnershipMapper) UpdateMany added in v0.1.18

func (mapper *OwnershipMapper) UpdateMany(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObjs []models.IModel) ([]models.IModel, error)

UpdateMany updates multiple models

func (*OwnershipMapper) UpdateOneWithID added in v0.1.18

func (mapper *OwnershipMapper) UpdateOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel, id datatypes.UUID) (models.IModel, error)

UpdateOneWithID updates model based on this json

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

func (*UserMapper) GetOneWithID

func (mapper *UserMapper) 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 (*UserMapper) UpdateOneWithID

func (mapper *UserMapper) UpdateOneWithID(db *gorm.DB, oid *datatypes.UUID, typeString string, modelObj models.IModel, id datatypes.UUID) (models.IModel, error)

UpdateOneWithID updates model based on this json

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL