cherryMongo

package module
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 9 Imported by: 0

README

mongo组件

  • 基于mongodb实现多数据实例管理

Install

Prerequisites
  • GO >= 1.17
Using go get
go get github.com/cherry-game/cherry/components/mongo@latest

Quick Start

import cherryMongo "github.com/cherry-game/cherry/components/mongo"

example

  • 示例代码待补充

Documentation

Index

Constants

View Source
const (
	Name = "mongo_component"
)

Variables

This section is empty.

Functions

func CreateDatabase

func CreateDatabase(uri, dbName string, timeout ...time.Duration) (*mongo.Database, error)

Types

type Component

type Component struct {
	cfacade.Component
	// contains filtered or unexported fields
}

func NewComponent

func NewComponent() *Component

func (*Component) GetDb

func (s *Component) GetDb(id string) *mongo.Database

func (*Component) GetDbMap

func (s *Component) GetDbMap(groupId string) (map[string]*mongo.Database, bool)

func (*Component) GetHashDb

func (s *Component) GetHashDb(groupId string, hashFn HashDb) (*mongo.Database, bool)

func (*Component) Init

func (s *Component) Init()

func (*Component) Name

func (*Component) Name() string

type HashDb

type HashDb func(dbMaps map[string]*mongo.Database) string

HashDb hash by group id

Jump to

Keyboard shortcuts

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