db

package
v0.0.0-...-8e06e88 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContext

func GetContext() (ctx context.Context)

限制每次操作数据库的操作时间为10s

func Use

func Use(client *mongo.Client, dbname, collname string) *mongo.Collection

选择数据库及表单

Types

type MongoDBClient

type MongoDBClient struct {
	*mongo.Client
}

使用mongoDB官方库进行数据库操作

func NewConnection

func NewConnection(uri string) (*MongoDBClient, error)

建立与mongodb的连接

func (*MongoDBClient) WebLogin

func (*MongoDBClient) WebRegister

func (odb *MongoDBClient) WebRegister(user request.WebRegisterData) (request.WebUser, error)

func (*MongoDBClient) WxLogin

func (odb *MongoDBClient) WxLogin(id string) (request.WxUser, error)

func (*MongoDBClient) WxRegister

func (odb *MongoDBClient) WxRegister(user request.WxUser) (request.WxUser, error)

实现数据库操作

type ODBLayer

type ODBLayer interface {
	WxRegister(request.WxUser) (request.WxUser, error)
	WxLogin(string) (request.WxUser, error)

	WebRegister(user request.WebRegisterData) (request.WebUser, error)
	WebLogin(request.WebLoginData) (request.WebLoginResponseData, error)
}

Jump to

Keyboard shortcuts

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