mango

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 13 Imported by: 0

README

mango

Mongo ODM for Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteMany

func DeleteMany(filter interface{}, value interface{}) error

func DeleteOne

func DeleteOne(filter interface{}, value interface{}) error

func FindOne

func FindOne(filter interface{}, value interface{}, ops ...*options.FindOne) error

func InsertOne

func InsertOne(value interface{}, ops ...*options.InsertOne) error

func SetContext

func SetContext(c context.Context, model interface{}) error

func UpdateOne

func UpdateOne(filter interface{}, operator *Operator, ops ...*options.Update) error

Types

type Config

type Config struct {
	options.Client
	Address  string
	Port     uint
	Srv      bool
	Timeout  *time.Time
	Database string
	Username string
	Password string
	Source   string
	Context  context.Context
}

type Connection

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

func Connect

func Connect(config *Config) (*Connection, error)

func (*Connection) GetClient

func (c *Connection) GetClient() *mongo.Client

func (*Connection) Register

func (c *Connection) Register(ctx context.Context, models ...interface{})

type D

type D bson.D

type Document

type Document struct {
	ID        primitive.ObjectID `bson:"_id"`
	CreatedAt *time.Time
	UpdatedAt *time.Time
	Context   context.Context
}

func Model

func Model(model interface{}) *Document

func (*Document) Connection

func (d *Document) Connection() *Connection

func (*Document) Find

func (d *Document) Find(filter interface{}, value interface{}, ops ...*options.Find) error

func (*Document) GetContext

func (m *Document) GetContext() context.Context

func (*Document) SetContext

func (m *Document) SetContext(c context.Context)

type M

type M bson.M

type Operator

type Operator struct {
	Operator string
	Value    interface{}
}

func Set

func Set(model interface{}) *Operator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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