datamapper

package
v0.4.17 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMapper added in v0.3.3

type BaseMapper struct {
	Service service.IService
}

BaseMapper is a basic CRUD manager

func (*BaseMapper) CreateMany added in v0.3.3

func (mapper *BaseMapper) CreateMany(db *gorm.DB, who models.Who, typeString string, modelObjs []models.IModel) ([]models.IModel, error)

CreateMany creates an instance of this model based on json and store it in db

func (*BaseMapper) CreateOne added in v0.3.3

func (mapper *BaseMapper) CreateOne(db *gorm.DB, who models.Who, typeString string, modelObj models.IModel) (models.IModel, error)

CreateOne creates an instance of this model based on json and store it in db

func (*BaseMapper) DeleteMany added in v0.3.3

func (mapper *BaseMapper) DeleteMany(db *gorm.DB, who models.Who, typeString string, modelObjs []models.IModel) ([]models.IModel, error)

DeleteMany deletes multiple models

func (*BaseMapper) DeleteOneWithID added in v0.3.3

func (mapper *BaseMapper) DeleteOneWithID(db *gorm.DB, who models.Who, typeString string, id *datatypes.UUID) (models.IModel, error)

DeleteOneWithID delete the model TODO: delete the groups associated with this record?

func (*BaseMapper) GetAll added in v0.3.3

func (mapper *BaseMapper) GetAll(db *gorm.DB, who models.Who, typeString string, options map[URLParam]interface{}) ([]models.IModel, []models.UserRole, *int, error)

GetAll 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 (*BaseMapper) GetOneWithID added in v0.3.3

func (mapper *BaseMapper) GetOneWithID(db *gorm.DB, who models.Who, typeString string, id *datatypes.UUID) (models.IModel, models.UserRole, error)

GetOneWithID get one model object based on its type and its id string

func (*BaseMapper) PatchMany added in v0.3.3

func (mapper *BaseMapper) PatchMany(db *gorm.DB, who models.Who, typeString string, jsonIDPatches []models.JSONIDPatch) ([]models.IModel, error)

PatchMany patches multiple models

func (*BaseMapper) PatchOneWithID added in v0.3.3

func (mapper *BaseMapper) PatchOneWithID(db *gorm.DB, who models.Who, typeString string, jsonPatch []byte, id *datatypes.UUID) (models.IModel, error)

PatchOneWithID updates model based on this json

func (*BaseMapper) UpdateMany added in v0.3.3

func (mapper *BaseMapper) UpdateMany(db *gorm.DB, who models.Who, typeString string, modelObjs []models.IModel) ([]models.IModel, error)

UpdateMany updates multiple models

func (*BaseMapper) UpdateOneWithID added in v0.3.3

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

UpdateOneWithID updates model based on this json

type IChangeEmailPasswordMapper added in v0.2.2

type IChangeEmailPasswordMapper interface {
	ChangeEmailPasswordWithID(db *gorm.DB, who models.Who,
		typeString string, modelobj models.IModel, id *datatypes.UUID) (models.IModel, error)
}

IChangeEmailPasswordMapper changes email and password

type IDataMapper added in v0.3.3

type IDataMapper interface {
	CreateOne(db *gorm.DB, who models.Who, typeString string, modelObj models.IModel) (models.IModel, error)

	CreateMany(db *gorm.DB, who models.Who, typeString string, modelObj []models.IModel) ([]models.IModel, error)

	GetOneWithID(db *gorm.DB, who models.Who,
		typeString string, id *datatypes.UUID) (models.IModel, models.UserRole, error)

	GetAll(db *gorm.DB, who models.Who,
		typeString string, options map[URLParam]interface{}) ([]models.IModel, []models.UserRole, *int, error)

	UpdateOneWithID(db *gorm.DB, who models.Who,
		typeString string, modelobj models.IModel, id *datatypes.UUID) (models.IModel, error)

	UpdateMany(db *gorm.DB, who models.Who,
		typeString string, modelObjs []models.IModel) ([]models.IModel, error)

	PatchOneWithID(db *gorm.DB, who models.Who,
		typeString string, jsonPatch []byte, id *datatypes.UUID) (models.IModel, error)

	PatchMany(db *gorm.DB, who models.Who,
		typeString string, jsonIDPatches []models.JSONIDPatch) ([]models.IModel, error)

	DeleteOneWithID(db *gorm.DB, who models.Who,
		typeString string, id *datatypes.UUID) (models.IModel, error)

	DeleteMany(db *gorm.DB, who models.Who,
		typeString string, modelObjs []models.IModel) ([]models.IModel, error)
}

IDataMapper has all the crud interfaces

func SharedGlobalMapper added in v0.1.46

func SharedGlobalMapper() IDataMapper

SharedGlobalMapper creats a singleton of Crud object

func SharedLinkTableMapper added in v0.3.0

func SharedLinkTableMapper() IDataMapper

SharedLinkTableMapper creats a singleton of Crud object

func SharedOrganizationMapper added in v0.1.28

func SharedOrganizationMapper() IDataMapper

SharedOrganizationMapper creats a singleton of Crud object

func SharedOwnershipMapper added in v0.1.18

func SharedOwnershipMapper() IDataMapper

SharedOwnershipMapper creats a singleton of Crud object

type URLParam added in v0.1.50

type URLParam string

URLParam is the URL parameter

const (
	URLParamOffset        URLParam = "offset"
	URLParamLimit         URLParam = "limit"
	URLParamOrder         URLParam = "order"
	URLParamLatestN       URLParam = "latestn"
	URLParamCstart        URLParam = "cstart"
	URLParamCstop         URLParam = "cstop"
	URLParamHasTotalCount URLParam = "totalcount"
	URLParamOtherQueries  URLParam = "better_otherqueries"
)

type UserMapper

type UserMapper struct {
	Service service.IService
}

UserMapper is a User CRUD manager

func SharedUserMapper

func SharedUserMapper() *UserMapper

SharedUserMapper creats a singleton of Crud object

func (*UserMapper) ChangeEmailPasswordWithID added in v0.2.2

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

ChangeEmailPasswordWithID changes email and/or password

func (*UserMapper) CreateMany added in v0.1.24

func (mapper *UserMapper) CreateMany(db *gorm.DB, who models.Who, typeString string, modelObj []models.IModel) ([]models.IModel, error)

CreateMany :-

func (*UserMapper) CreateOne

func (mapper *UserMapper) CreateOne(db *gorm.DB, who models.Who, 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) DeleteMany added in v0.3.3

func (mapper *UserMapper) DeleteMany(db *gorm.DB, who models.Who,
	typeString string, modelObjs []models.IModel) ([]models.IModel, error)

DeleteMany :-

func (*UserMapper) DeleteOneWithID

func (mapper *UserMapper) DeleteOneWithID(db *gorm.DB, who models.Who, typeString string, id *datatypes.UUID) (models.IModel, error)

DeleteOneWithID deletes the user with the ID

func (*UserMapper) GetAll added in v0.3.3

func (mapper *UserMapper) GetAll(db *gorm.DB, who models.Who, typeString string, options map[URLParam]interface{}) ([]models.IModel, []models.UserRole, *int, error)

GetAll :-

func (*UserMapper) GetOneWithID

func (mapper *UserMapper) GetOneWithID(db *gorm.DB, who models.Who, 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) PatchMany added in v0.3.3

func (mapper *UserMapper) PatchMany(db *gorm.DB, who models.Who,
	typeString string, jsonIDPatches []models.JSONIDPatch) ([]models.IModel, error)

PatchMany :-

func (*UserMapper) PatchOneWithID added in v0.3.3

func (mapper *UserMapper) PatchOneWithID(db *gorm.DB, who models.Who,
	typeString string, jsonPatch []byte, id *datatypes.UUID) (models.IModel, error)

PatchOneWithID :-

func (*UserMapper) UpdateMany added in v0.3.3

func (mapper *UserMapper) UpdateMany(db *gorm.DB, who models.Who, typeString string, modelObjs []models.IModel) ([]models.IModel, error)

UpdateMany :-

func (*UserMapper) UpdateOneWithID

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

UpdateOneWithID updates model based on this json Update DOESN'T change password. It'll load up the password hash and save the same. Update password require special endpoint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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