db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 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{}, opts *options.InsertOneOpts) (string, error)

	// Inserts return ids
	Inserts(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{}, opts *options.UpdateOpts) (*result.UpdateResult, error)

	// Updates return *result.UpdateResult,error
	Updates(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{}, opts *options.DeleteOpts) (*result.DeleteResult, error)

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

	// Count return int64,error
	Count(ctx context.Context, collectionName string, filter interface{}, opts *options.CountOpts) (int64, 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