datamapper

package
v0.5.22 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLinkTableMapper added in v0.4.48

func SetLinkTableMapper(mapper IDataMapper)

SetLinkTableMapper allows one to mock LinkTableMapper for testing

func SetMockOwnershipMapper added in v0.4.48

func SetMockOwnershipMapper(mapper IDataMapper)

SetMockOwnershipMapper allows one to mock OrganizationMapper for testing

func SetOrganizationMapper added in v0.4.48

func SetOrganizationMapper(mapper IDataMapper)

SetOrganizationMapper allows one to mock OrganizationMapper for testing

func SetSharedGlobalMapper added in v0.4.48

func SetSharedGlobalMapper(mapper IDataMapper)

SetSharedGlobalMapper allows one to mock SharedGlobalMapper for testing

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,
	options *map[urlparam.Param]interface{}, cargo *models.BatchHookCargo) ([]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,
	options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (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,
	options *map[urlparam.Param]interface{}, cargo *models.BatchHookCargo) ([]models.IModel, error)

DeleteMany deletes multiple models

func (*BaseMapper) DeleteOne added in v0.5.0

func (mapper *BaseMapper) DeleteOne(db *gorm.DB, who models.Who, typeString string,
	id *datatypes.UUID, options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (models.IModel, error)

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

func (*BaseMapper) PatchMany added in v0.3.3

func (mapper *BaseMapper) PatchMany(db *gorm.DB, who models.Who, typeString string,
	jsonIDPatches []models.JSONIDPatch, options *map[urlparam.Param]interface{},
	cargo *models.BatchHookCargo) ([]models.IModel, error)

PatchMany patches multiple models

func (*BaseMapper) PatchOne added in v0.5.0

func (mapper *BaseMapper) PatchOne(db *gorm.DB, who models.Who, typeString string, jsonPatch []byte,
	id *datatypes.UUID, options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (models.IModel, error)

PatchOne updates model based on this json

func (*BaseMapper) ReadMany added in v0.5.0

func (mapper *BaseMapper) ReadMany(db *gorm.DB, who models.Who, typeString string,
	options *map[urlparam.Param]interface{}, cargo *models.BatchHookCargo) ([]models.IModel, []models.UserRole, *int, error)

func (*BaseMapper) ReadOne added in v0.5.0

func (mapper *BaseMapper) ReadOne(db *gorm.DB, who models.Who, typeString string, id *datatypes.UUID,
	options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (models.IModel, models.UserRole, error)

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

func (*BaseMapper) UpdateMany added in v0.3.3

func (mapper *BaseMapper) UpdateMany(db *gorm.DB, who models.Who, typeString string,
	modelObjs []models.IModel, options *map[urlparam.Param]interface{},
	cargo *models.BatchHookCargo) ([]models.IModel, error)

UpdateMany updates multiple models

func (*BaseMapper) UpdateOne added in v0.5.0

func (mapper *BaseMapper) UpdateOne(db *gorm.DB, who models.Who, typeString string,
	modelObj models.IModel, id *datatypes.UUID, options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (models.IModel, error)

UpdateOne 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,
		options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (models.IModel, error)

	CreateMany(db *gorm.DB, who models.Who, typeString string, modelObj []models.IModel,
		options *map[urlparam.Param]interface{}, cargo *models.BatchHookCargo) ([]models.IModel, error)

	ReadOne(db *gorm.DB, who models.Who,
		typeString string, id *datatypes.UUID, options *map[urlparam.Param]interface{},
		cargo *models.ModelCargo) (models.IModel, models.UserRole, error)

	ReadMany(db *gorm.DB, who models.Who,
		typeString string, options *map[urlparam.Param]interface{},
		cargo *models.BatchHookCargo) ([]models.IModel, []models.UserRole, *int, error)

	UpdateOne(db *gorm.DB, who models.Who,
		typeString string, modelobj models.IModel, id *datatypes.UUID,
		options *map[urlparam.Param]interface{},
		cargo *models.ModelCargo) (models.IModel, error)

	UpdateMany(db *gorm.DB, who models.Who,
		typeString string, modelObjs []models.IModel,
		options *map[urlparam.Param]interface{},
		cargo *models.BatchHookCargo) ([]models.IModel, error)

	PatchOne(db *gorm.DB, who models.Who,
		typeString string, jsonPatch []byte, id *datatypes.UUID,
		options *map[urlparam.Param]interface{},
		cargo *models.ModelCargo) (models.IModel, error)

	PatchMany(db *gorm.DB, who models.Who,
		typeString string, jsonIDPatches []models.JSONIDPatch,
		options *map[urlparam.Param]interface{},
		cargo *models.BatchHookCargo) ([]models.IModel, error)

	DeleteOne(db *gorm.DB, who models.Who,
		typeString string, id *datatypes.UUID, options *map[urlparam.Param]interface{},
		cargo *models.ModelCargo) (models.IModel, error)

	DeleteMany(db *gorm.DB, who models.Who,
		typeString string, modelObjs []models.IModel,
		options *map[urlparam.Param]interface{},
		cargo *models.BatchHookCargo) ([]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 IEmailVerificationMapper added in v0.4.25

type IEmailVerificationMapper interface {
	SendEmailVerification(db *gorm.DB, who models.Who, typeString string, modelObj models.IModel) error
	VerifyEmail(db *gorm.DB, typeString string, id *datatypes.UUID, code string) error
}

IEmailVerificationMapper does verification email

type IResetPasswordMapper added in v0.4.23

type IResetPasswordMapper interface {
	SendEmailResetPassword(db *gorm.DB, who models.Who, typeString string, modelObj models.IModel) error
	ResetPassword(db *gorm.DB, typeString string, modelObj models.IModel, id *datatypes.UUID, code string) error
}

IResetPasswordMapper reset password in-case user forgotten it.

type ISendPasswordResetEmail added in v0.4.23

type ISendPasswordResetEmail interface {
	SendPasswordResetEmail(db *gorm.DB, who models.Who,
		typeString string, modelobj models.IModel) error
}

ISendVerificationEmailHandler for sending verification email (Should be impelemented in model) This is for user model

type ISendVerificationEmail added in v0.4.23

type ISendVerificationEmail interface {
	SendVerificationEmail(db *gorm.DB, who models.Who,
		typeString string, modelobj models.IModel, actionType datatypes.VerificationActionType) error
}

ISendVerificationEmailHandler for sending verification email (Should be impelemented in model) This is for user model

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, options *map[urlparam.Param]interface{}, cargo *models.BatchHookCargo) ([]models.IModel, error)

CreateMany :-

func (*UserMapper) CreateOne

func (mapper *UserMapper) CreateOne(db *gorm.DB, who models.Who, typeString string, modelObj models.IModel,
	options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (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, options *map[urlparam.Param]interface{},
	cargo *models.BatchHookCargo) ([]models.IModel, error)

DeleteMany :-

func (*UserMapper) DeleteOne added in v0.5.0

func (mapper *UserMapper) DeleteOne(db *gorm.DB, who models.Who, typeString string, id *datatypes.UUID,
	options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (models.IModel, error)

DeleteOne deletes the user with the ID

func (*UserMapper) PatchMany added in v0.3.3

func (mapper *UserMapper) PatchMany(db *gorm.DB, who models.Who,
	typeString string, jsonIDPatches []models.JSONIDPatch, options *map[urlparam.Param]interface{},
	cargo *models.BatchHookCargo) ([]models.IModel, error)

PatchMany :-

func (*UserMapper) PatchOne added in v0.5.0

func (mapper *UserMapper) PatchOne(db *gorm.DB, who models.Who, typeString string, jsonPatch []byte,
	id *datatypes.UUID, options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (models.IModel, error)

PatchOne updates model based on this json

func (*UserMapper) ReadMany added in v0.5.0

func (mapper *UserMapper) ReadMany(db *gorm.DB, who models.Who, typeString string,
	options *map[urlparam.Param]interface{}, cargo *models.BatchHookCargo) ([]models.IModel, []models.UserRole, *int, error)

ReadMany :-

func (*UserMapper) ReadOne added in v0.5.0

func (mapper *UserMapper) ReadOne(db *gorm.DB, who models.Who, typeString string,
	id *datatypes.UUID, options *map[urlparam.Param]interface{}, cargo *models.ModelCargo) (models.IModel, models.UserRole, error)

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

func (*UserMapper) ResetPassword added in v0.4.23

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

func (*UserMapper) SendEmailResetPassword added in v0.4.25

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

SendEmailResetPassword :- Calling this allow a way to change password by the verification code without logging in. But doens't mean the password is already invalidated

func (*UserMapper) SendEmailVerification added in v0.4.23

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

func (*UserMapper) UpdateMany added in v0.3.3

func (mapper *UserMapper) UpdateMany(db *gorm.DB, who models.Who, typeString string,
	modelObjs []models.IModel, options *map[urlparam.Param]interface{}, cargo *models.BatchHookCargo) ([]models.IModel, error)

UpdateMany :-

func (*UserMapper) UpdateOne added in v0.5.0

func (mapper *UserMapper) UpdateOne(db *gorm.DB, who models.Who, typeString string,
	modelObj models.IModel, id *datatypes.UUID, options *map[urlparam.Param]interface{},
	cargo *models.ModelCargo) (models.IModel, error)

UpdateOne 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

func (*UserMapper) VerifyEmail added in v0.4.25

func (mapper *UserMapper) VerifyEmail(db *gorm.DB, typeString string, id *datatypes.UUID, code string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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