model

package
v0.0.0-...-98849e2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

DemoSet 注入Demo

MenuActionResourceSet 注入MenuActionResource

MenuActionSet 注入MenuAction

MenuSet 注入Menu

ModelSet model注入

RoleMenuSet 注入RoleMenu

RoleSet 注入Role

TransSet 注入Trans

UserRoleSet 注入UserRole

UserSet 注入User

Functions

func DefaultFilter

func DefaultFilter(ctx context.Context, params ...bson.E) bson.D

DefaultFilter 默认的查询参数

func Delete

func Delete(ctx context.Context, c *mongo.Collection, filter interface{}) error

Delete 删除数据

func DeleteMany

func DeleteMany(ctx context.Context, c *mongo.Collection, filter interface{}) error

DeleteMany 删除多条数据

func ExecTrans

func ExecTrans(ctx context.Context, cli *mongo.Client, fn TransFunc) error

ExecTrans 执行事务

func Filter

func Filter(key string, value interface{}) bson.E

Filter 过滤

func FindOne

func FindOne(ctx context.Context, c *mongo.Collection, filter, out interface{}) (bool, error)

FindOne 查询单条数据

func FindPage

func FindPage(ctx context.Context, c *mongo.Collection, pp schema.PaginationParam, filter interface{}, out interface{}, opts ...*options.FindOptions) (int, error)

FindPage 查询分页数据

func Insert

func Insert(ctx context.Context, c *mongo.Collection, doc interface{}) error

Insert 插入数据

func InsertMany

func InsertMany(ctx context.Context, c *mongo.Collection, docs ...interface{}) error

InsertMany 插入多条数据

func OrRegexFilter

func OrRegexFilter(key, value string) bson.M

OrRegexFilter 正则过滤($or)

func ParseOrder

func ParseOrder(items []*schema.OrderField, handle ...OrderFieldFunc) bson.D

ParseOrder 解析排序字段

func RegexFilter

func RegexFilter(key, value string) bson.E

RegexFilter 正则过滤

func Update

func Update(ctx context.Context, c *mongo.Collection, filter, doc interface{}) error

Update 更新数据

func UpdateFields

func UpdateFields(ctx context.Context, c *mongo.Collection, filter, doc interface{}) error

UpdateFields 更新指定字段数据

func UpdateMany

func UpdateMany(ctx context.Context, c *mongo.Collection, filter, doc interface{}) error

UpdateMany 更新多条数据

func UpdateManyFields

func UpdateManyFields(ctx context.Context, c *mongo.Collection, filter, doc interface{}) error

UpdateManyFields 更新多条指定字段的数据

func WrapPageQuery

func WrapPageQuery(ctx context.Context, c *mongo.Collection, pp schema.PaginationParam, filter interface{}, out interface{}, opts ...*options.FindOptions) (*schema.PaginationResult, error)

WrapPageQuery 包装带有分页的查询

Types

type Demo

type Demo struct {
	Client *mongo.Client
}

Demo 示例存储

func (*Demo) Create

func (a *Demo) Create(ctx context.Context, item schema.Demo) error

Create 创建数据

func (*Demo) Delete

func (a *Demo) Delete(ctx context.Context, id string) error

Delete 删除数据

func (*Demo) Get

func (a *Demo) Get(ctx context.Context, id string, opts ...schema.DemoQueryOptions) (*schema.Demo, error)

Get 查询指定数据

func (*Demo) Query

Query 查询数据

func (*Demo) Update

func (a *Demo) Update(ctx context.Context, id string, item schema.Demo) error

Update 更新数据

func (*Demo) UpdateStatus

func (a *Demo) UpdateStatus(ctx context.Context, id string, status int) error

UpdateStatus 更新状态

type Menu struct {
	Client *mongo.Client
}

Menu 菜单存储

func (a *Menu) Create(ctx context.Context, item schema.Menu) error

Create 创建数据

func (a *Menu) Delete(ctx context.Context, id string) error

Delete 删除数据

func (a *Menu) Get(ctx context.Context, id string, opts ...schema.MenuQueryOptions) (*schema.Menu, error)

Get 查询指定数据

Query 查询数据

func (a *Menu) Update(ctx context.Context, id string, item schema.Menu) error

Update 更新数据

func (a *Menu) UpdateParentPath(ctx context.Context, id, parentPath string) error

UpdateParentPath 更新父级路径

func (a *Menu) UpdateStatus(ctx context.Context, id string, status int) error

UpdateStatus 更新状态

type MenuAction struct {
	Client *mongo.Client
}

MenuAction 菜单动作存储

func (a *MenuAction) Create(ctx context.Context, item schema.MenuAction) error

Create 创建数据

func (a *MenuAction) Delete(ctx context.Context, id string) error

Delete 删除数据

func (a *MenuAction) DeleteByMenuID(ctx context.Context, menuID string) error

DeleteByMenuID 根据菜单ID删除数据

Get 查询指定数据

Query 查询数据

func (a *MenuAction) Update(ctx context.Context, id string, item schema.MenuAction) error

Update 更新数据

type MenuActionResource struct {
	Client *mongo.Client
}

MenuActionResource 菜单动作关联资源存储

Create 创建数据

func (a *MenuActionResource) Delete(ctx context.Context, id string) error

Delete 删除数据

func (a *MenuActionResource) DeleteByActionID(ctx context.Context, actionID string) error

DeleteByActionID 根据动作ID删除数据

func (a *MenuActionResource) DeleteByMenuID(ctx context.Context, menuID string) error

DeleteByMenuID 根据菜单ID删除数据

Get 查询指定数据

Query 查询数据

Update 更新数据

type OrderFieldFunc

type OrderFieldFunc func(string) string

OrderFieldFunc 排序字段转换函数

type Role

type Role struct {
	Client *mongo.Client
}

Role 角色存储

func (*Role) Create

func (a *Role) Create(ctx context.Context, item schema.Role) error

Create 创建数据

func (*Role) Delete

func (a *Role) Delete(ctx context.Context, id string) error

Delete 删除数据

func (*Role) Get

func (a *Role) Get(ctx context.Context, id string, opts ...schema.RoleQueryOptions) (*schema.Role, error)

Get 查询指定数据

func (*Role) Query

Query 查询数据

func (*Role) Update

func (a *Role) Update(ctx context.Context, id string, item schema.Role) error

Update 更新数据

func (*Role) UpdateStatus

func (a *Role) UpdateStatus(ctx context.Context, id string, status int) error

UpdateStatus 更新状态

type RoleMenu

type RoleMenu struct {
	Client *mongo.Client
}

RoleMenu 角色菜单存储

func (*RoleMenu) Create

func (a *RoleMenu) Create(ctx context.Context, item schema.RoleMenu) error

Create 创建数据

func (*RoleMenu) Delete

func (a *RoleMenu) Delete(ctx context.Context, id string) error

Delete 删除数据

func (*RoleMenu) DeleteByRoleID

func (a *RoleMenu) DeleteByRoleID(ctx context.Context, roleID string) error

DeleteByRoleID 根据角色ID删除数据

func (*RoleMenu) Get

Get 查询指定数据

func (*RoleMenu) Query

Query 查询数据

func (*RoleMenu) Update

func (a *RoleMenu) Update(ctx context.Context, id string, item schema.RoleMenu) error

Update 更新数据

type Trans

type Trans struct {
	Client *mongo.Client
}

Trans 事务管理

func (*Trans) Exec

func (a *Trans) Exec(ctx context.Context, fn func(context.Context) error) error

Exec 执行事务

type TransFunc

type TransFunc func(context.Context) error

TransFunc 定义事务执行函数

type User

type User struct {
	Client *mongo.Client
}

User 用户存储

func (*User) Create

func (a *User) Create(ctx context.Context, item schema.User) error

Create 创建数据

func (*User) Delete

func (a *User) Delete(ctx context.Context, id string) error

Delete 删除数据

func (*User) Get

func (a *User) Get(ctx context.Context, id string, opts ...schema.UserQueryOptions) (*schema.User, error)

Get 查询指定数据

func (*User) Query

Query 查询数据

func (*User) Update

func (a *User) Update(ctx context.Context, id string, item schema.User) error

Update 更新数据

func (*User) UpdatePassword

func (a *User) UpdatePassword(ctx context.Context, id, password string) error

UpdatePassword 更新密码

func (*User) UpdateStatus

func (a *User) UpdateStatus(ctx context.Context, id string, status int) error

UpdateStatus 更新状态

type UserRole

type UserRole struct {
	Client *mongo.Client
}

UserRole 用户角色存储

func (*UserRole) Create

func (a *UserRole) Create(ctx context.Context, item schema.UserRole) error

Create 创建数据

func (*UserRole) Delete

func (a *UserRole) Delete(ctx context.Context, id string) error

Delete 删除数据

func (*UserRole) DeleteByUserID

func (a *UserRole) DeleteByUserID(ctx context.Context, userID string) error

DeleteByUserID 根据用户ID删除数据

func (*UserRole) Get

Get 查询指定数据

func (*UserRole) Query

Query 查询数据

func (*UserRole) Update

func (a *UserRole) Update(ctx context.Context, id string, item schema.UserRole) error

Update 更新数据

Jump to

Keyboard shortcuts

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