storage

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 9 Imported by: 0

README

go-mongo-store

ReportCard GoDoc License

Quick Start

Download and install
$ go get -u -v gopkg.in/nodely/go-mongo-store.v1

MIT License

Copyright (c) 2019 Nodely

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CRUD

type CRUD interface {
	GetItem(id primitive.ObjectID, t reflect.Type) (interface{}, error)
	SaveItem(id primitive.ObjectID, d interface{}) error
	UpdateOne(filter interface{}, d interface{}) (int64, error)

	Insert(d ...interface{}) ([]interface{}, error)

	Find(filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
	FindOne(filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult

	DeleteOne(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

	Count(filter interface{}) int64

	EnsureIndex(key string)
	EnsureIndexesRaw(idx mongo.IndexModel) error
}

CRUD interface

type DbStorage

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

DbStorage struct

func NewMongoStorage

func NewMongoStorage(connection string) (*DbStorage, error)

NewMongoStorage initialize connection to storage

func (*DbStorage) Close

func (db *DbStorage) Close()

Close func

func (*DbStorage) GetDbCollection

func (db *DbStorage) GetDbCollection(collection string) CRUD

GetDbCollection func

func (*DbStorage) WithName

func (db *DbStorage) WithName(name string) *DbStorage

WithName adds db name to context

Jump to

Keyboard shortcuts

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