db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db interface {
	// Close Db connect
	Close(ctx context.Context) error

	// Insert return id
	Insert(ctx context.Context, collectionName string, doc interface{}) (string, error)
	// InsertWithOptions return id
	InsertWithOptions(ctx context.Context, collectionName string, doc interface{}, opts *options.InsertOpts) (string, error)

	// Inserts return ids
	Inserts(ctx context.Context, collectionName string, docs []interface{}) ([]string, error)
	// InsertsWithOptions return ids
	InsertsWithOptions(ctx context.Context, collectionName string, docs []interface{}, opts *options.InsertOpts) ([]string, error)

	// Find return Entity
	Find(ctx context.Context, collectionName string, filter interface{}, opts options.FindOpts) (*entity.Entity, error)
	// Find return []Entity
	Finds(ctx context.Context, collectionName string, filter interface{}, opts options.FindOpts) ([]*entity.Entity, error)

	// Update just update at most one document in the collection and return *result.UpdateResult,error
	Update(ctx context.Context, collectionName string, filter interface{}, update interface{}) (*result.UpdateResult, error)
	// UpdateWithOptions just update at most one document in the collection and return *result.UpdateResult,error
	UpdateWithOptions(ctx context.Context, collectionName string, filter interface{}, update interface{}, opts options.UpdateOpts) (*result.UpdateResult, error)

	// Updates return *result.UpdateResult,error
	Updates(ctx context.Context, collectionName string, filter interface{}, update interface{}) (*result.UpdateResult, error)
	// UpdatesWithOptions return *result.UpdateResult,error
	UpdatesWithOptions(ctx context.Context, collectionName string, filter interface{}, update interface{}, opts options.UpdateOpts) (*result.UpdateResult, error)

	//Delete at most one document from the collection.  return DeleteResult,error
	Delete(ctx context.Context, collectionName string, filter interface{}) (*result.DeleteResult, error)
	//DeleteWithOptions at most one document from the collection.  return DeleteResult,error
	DeleteWithOptions(ctx context.Context, collectionName string, filter interface{}, opts options.DeleteOpts) (*result.DeleteResult, error)

	// Deletes return *result.DeleteResult,error
	Deletes(ctx context.Context, collectionName string, filter interface{}) (*result.DeleteResult, error)
	// DeletesWithOptions return *result.DeleteResult,error
	DeletesWithOptions(ctx context.Context, collectionName string, filter interface{}, opts options.DeleteOpts) (*result.DeleteResult, error)
}

Db is databases access interface

func New

func New(config *connect.Config) Db

New Db by config

Jump to

Keyboard shortcuts

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