mongo

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

* @Author: lisheng * @Date: 2022-10-14 16:28:38 * @LastEditTime: 2023-01-06 14:14:58 * @LastEditors: lisheng * @Description: mongoDB驱动 * @FilePath: /jf-go-kit/database/mongo/mongo.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDBEngnine

func CreateDBEngnine(addr string, port int) *mongo.Client

func DBKeepAlive

func DBKeepAlive()

*

  • @description: 心跳监测
  • @return {*}
  • @author: liqiyuWorks

func DeleteRecord

func DeleteRecord(engineName string, tableName string, deleteMap *map[string]string) (int64, error)

*

  • @description: D - 删除数据
  • @param {string} tableName
  • @param {*map[string]string} deleteMap
  • @return {*}
  • @author: liqiyuWorks

func ExistByQueryMap

func ExistByQueryMap(engineName string, tableName string, queryMap *map[string]string, user interface{}) (bool, error)

*

  • @description: R - 根据查询条件查看是否存在该条记录
  • @param {string} tableName
  • @param {*map[string]string} queryMap
  • @param {interface{}} user
  • @return {*}
  • @author: liqiyuWorks

func FindRecords

func FindRecords(engineName string, tableName string, queryMap *map[string]string, objPtr interface{}, pagerArg ...Pagination) error

*

  • @description: R - 查询多条数据
  • @param {string} tableName
  • @param {*map[string]string} queryMap: 查询map{"username": "jiufang"}
  • @param {interface{}} objPtr: 绑定查询对象
  • @param {...Pagination} pagerArg: 分页器,可传入指定的分页
  • @return {*}
  • @author: liqiyuWorks

func InitMgocli

func InitMgocli() func() error

func InsertRecord

func InsertRecord(engineName string, tableName string, objPtr interface{}) (int64, error)

*

  • @description: C-插入数据
  • @param {string} tableName
  • @param {interface{}} objPtr
  • @return {*}
  • @author: liqiyuWorks

func QueryRecord

func QueryRecord(engineName string, tableName string, queryMap *map[string]interface{}, objPtr interface{}) error

*

  • @description: R - 获取单条记录
  • @param {string} tableName
  • @param {*map[string]string} queryMap
  • @param {interface{}} objPtr
  • @return {*}
  • @author: liqiyuWorks

func UpateRecord

func UpateRecord(engineName string, tableName string, queryMap *map[string]string, updateMap *map[string]map[string]string) (int64, error)

*

  • @description: U - 更新数据
  • @param {string} tableName
  • @param {*map[string]string} queryMap
  • @param {*map[string]string} updateMap
  • @param {interface{}} objPtr
  • @return {*}
  • @author: liqiyuWorks

Types

type MgoManager

type MgoManager struct {
	EngineMap map[string]*mongo.Client
}
var (
	GMgoManager *MgoManager = new(MgoManager)
)

type Pagination

type Pagination struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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