orm

package
v0.0.0-...-5a5c7ff Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2021 utils. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTables

func CreateTables(v interface{})

请自行定

func DB

func DB() *gorm.DB

SetDB gorm对象

func DbCount

func DbCount(model, where interface{}) int64

DbCount 数目

func DbCreate

func DbCreate(model interface{}) error

DbCreate 创建

func DbDeleteBy

func DbDeleteBy(model interface{}, where string, args ...interface{}) (count int64, err error)

DbDeleteBy 删除

func DbDeleteByIds

func DbDeleteByIds(model, ids interface{}) error

DbDeleteByIds 批量删除 ids id数组 []

func DbDeletes

func DbDeletes(value interface{}) error

DbDeletes 批量删除

func DbFind

func DbFind(out interface{}, orders ...string) error

DbFind 多个查找

func DbFindBy

func DbFindBy(out interface{}, where string, args ...interface{}) (int64, error)

DbFindBy 多个条件查找

func DbFindPage

func DbFindPage(query string, obj interface{}, page, size int) (int64, error)

DbFindPageRaw obj必须是数组类型

func DbFirstBy

func DbFirstBy(out interface{}, where string, args ...interface{}) (err error)

DbFirstBy 指定条件查找

func DbFirstByID

func DbFirstByID(out interface{}, id uint) error

DbFirstByID 查找

func DbFirstWhere

func DbFirstWhere(out, where interface{}) error

DbFirstWhere 查找

func DbSave

func DbSave(value interface{}) error

DbSave 保存

func DbUpdateByID

func DbUpdateByID(model, id interface{}) error

DbUpdateByID 更新

func DbUpdateByIds

func DbUpdateByIds(model interface{}, ids interface{}, value map[string]interface{}) error

DbUpdateByIds 批量更新 ids id数组

func DbUpdateColByID

func DbUpdateColByID(model, id interface{}, column string, value interface{}) error

DbUpdateColByID 单列更新

func DbUpdateModel

func DbUpdateModel(model interface{}) error

DbUpdateModel 更新

func DbUpdateModelBy

func DbUpdateModelBy(model interface{}, where string, args ...interface{}) error

DbUpdateModelBy 条件更新

func Model

func Model(v interface{}) *gorm.DB

func NewGormV2

func NewGormV2(name, address string) (db *gorm.DB, err error)

func Partition

func Partition(m interface{}) *partition

func SetDB

func SetDB(db *gorm.DB)

SetDB gorm对象

func Table

func Table(v interface{}) *gorm.DB

Types

type DbPage

type DbPage struct {
	Num  int `form:"pageNum"`  // 当前页码
	Size int `form:"pageSize"` // 每页数
}

func (*DbPage) DbWhere

func (o *DbPage) DbWhere() *DbWhere

type DbWhere

type DbWhere struct {
	Orders []string
	// contains filtered or unexported fields
}

DbWhere 搜索条件

func (*DbWhere) Add

func (o *DbWhere) Add(query string, args ...interface{}) *DbWhere

Add 添加条件

func (*DbWhere) DateRange

func (o *DbWhere) DateRange(field string, r []string) *DbWhere

DateRange

func (*DbWhere) Equal

func (o *DbWhere) Equal(field string, v interface{}) *DbWhere

Equal

func (*DbWhere) EqualNumber

func (o *DbWhere) EqualNumber(field, v string) *DbWhere

EqualNumber

func (*DbWhere) Find

func (o *DbWhere) Find(out interface{}, conds ...interface{}) (int64, error)

func (*DbWhere) In

func (o *DbWhere) In(query, values string) *DbWhere

In values ,分割

func (*DbWhere) Joins

func (o *DbWhere) Joins(query string, args ...interface{}) *DbWhere

Joins join

func (*DbWhere) Like

func (o *DbWhere) Like(field, v string) *DbWhere

Like

func (*DbWhere) Model

func (o *DbWhere) Model(m interface{}) *DbWhere

DbByWhere

func (*DbWhere) Preload

func (o *DbWhere) Preload(preloads ...string) *DbWhere

Preload 关联加载

func (*DbWhere) PreloadWith

func (o *DbWhere) PreloadWith(query string, args ...interface{}) *DbWhere

Preload 关联加载

func (*DbWhere) Scan

func (o *DbWhere) Scan(out interface{}) (int64, error)

func (*DbWhere) TimeRange

func (o *DbWhere) TimeRange(field string, st, et string) *DbWhere

DateRange

type H

type H map[string]interface{}

H 多列处理

type XTablers

type XTablers interface {
	TableName() string       // 默认创建表
	TableNameOf(uint) string // 获取分区表
	TableCount() uint
}

Jump to

Keyboard shortcuts

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