mongodb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Example
package main

import ()

func main() {

}
Output:

Index

Examples

Constants

View Source
const (
	DatabaseName      = "gameserver"
	DBTimeOutDuration = time.Second * 30
	AutoIdTableName   = "__auto__id"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoId

type AutoId struct {
	Name string
	Id   int
}

type DBIndex

type DBIndex struct {
	Key  map[string]int
	NS   string
	Name string
}

type MongoOptions

type MongoOptions struct {
	DBUser string
	DBPwd  string
	DBName string
	DBAddr string
	DBPort string
}

type MongoRepo

type MongoRepo struct {
	MongoOptions
	Client *mongo.Client
}

func NewMongoRepo

func NewMongoRepo(options MongoOptions) (*MongoRepo, error)

func (*MongoRepo) Count

func (r *MongoRepo) Count(tableName string, filter interface{}, opts ...*options.CountOptions) (int64, error)

func (*MongoRepo) CreateDefaultIndex

func (r *MongoRepo) CreateDefaultIndex(tableName string, keys []string) (err error)

func (*MongoRepo) DeleteMany

func (r *MongoRepo) DeleteMany(tableName string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*MongoRepo) DeleteOne

func (r *MongoRepo) DeleteOne(tableName string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*MongoRepo) Drop

func (r *MongoRepo) Drop(tableName string) error

func (*MongoRepo) Find

func (r *MongoRepo) Find(tableName string, filter interface{}, opts ...*options.FindOptions) (context.Context, mongo.Cursor, error)

func (*MongoRepo) FindOne

func (r *MongoRepo) FindOne(tableName string, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult

func (*MongoRepo) FindOneAndReplace

func (r *MongoRepo) FindOneAndReplace(tableName string, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult

func (*MongoRepo) FindOneAndUpdate

func (r *MongoRepo) FindOneAndUpdate(tableName string, filter interface{}, replacement interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult

func (*MongoRepo) GetAutoId

func (r *MongoRepo) GetAutoId(name string, baseId int) (id int)

func (*MongoRepo) GetClient

func (r *MongoRepo) GetClient() (client *mongo.Client)

func (*MongoRepo) InsertMany

func (r *MongoRepo) InsertMany(tableName string, document []interface{}, opts ...*options.InsertManyOptions) (err error)

func (*MongoRepo) InsertOne

func (r *MongoRepo) InsertOne(tableName string, document interface{}, opts ...*options.InsertOneOptions) (err error)

func (*MongoRepo) ReplaceOne

func (r *MongoRepo) ReplaceOne(tableName string, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

func (*MongoRepo) UpdateMany

func (r *MongoRepo) UpdateMany(tableName string, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*MongoRepo) UpdateOne

func (r *MongoRepo) UpdateOne(tableName string, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*MongoRepo) UpdateOneOrInsert

func (r *MongoRepo) UpdateOneOrInsert(tableName string, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

Jump to

Keyboard shortcuts

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