datamapper

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: May 7, 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

Types

type BasicMapper

type BasicMapper struct {
}

BasicMapper is a basic CRUD manager

func SharedBasicMapper

func SharedBasicMapper() *BasicMapper

SharedBasicMapper creats a singleton of Crud object

func (*BasicMapper) CreateOne

func (mapper *BasicMapper) 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 (*BasicMapper) DeleteMany

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

DeleteMany deletes multiple models

func (*BasicMapper) DeleteOneWithID

func (mapper *BasicMapper) 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 (*BasicMapper) GetOneWithID

func (mapper *BasicMapper) 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 (*BasicMapper) PatchOneWithID

func (mapper *BasicMapper) 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 (*BasicMapper) ReadAll

func (mapper *BasicMapper) 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 (*BasicMapper) UpdateMany

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

UpdateMany updates multiple models

func (*BasicMapper) UpdateOneWithID

func (mapper *BasicMapper) 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 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)
}

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 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