dbm

package module
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Before = options.Before
	After  = options.After
)
View Source
const (
	Default       = options.Default
	Off           = options.Off
	Required      = options.Required
	UpdateLookup  = options.UpdateLookup
	WhenAvailable = options.WhenAvailable
)
View Source
const (
	NonTailable   = options.NonTailable
	Tailable      = options.Tailable
	TailableAwait = options.TailableAwait
)
View Source
const (
	OperationTypeInsert     = "insert"
	OperationTypeDelete     = "delete"
	OperationTypeReplace    = "replace"
	OperationTypeUpdate     = "update"
	OperationTypeInvalidate = "invalidate"
)

Variables

View Source
var ErrNoDocuments = mongo.ErrNoDocuments
View Source
var ErrResultNotSlice = errors.New("results argument must be a pointer to a slice")
View Source
var ErrSessionNotSupported = errors.New("session not supported")

Functions

func CompareServerVersions

func CompareServerVersions(v1 string, v2 string) int

func IsValidObjectId

func IsValidObjectId(s string) bool

Types

type A

type A = bson.A

An A is an ordered representation of a BSON array.

func NA

func NA(items ...interface{}) A

type Aggregate

type Aggregate interface {
	AllowDiskUse(b bool) Aggregate

	BatchSize(n int32) Aggregate

	BypassDocumentValidation(b bool) Aggregate

	Collation(c *Collation) Aggregate

	Comment(s string) Aggregate

	Hint(hint interface{}) Aggregate

	MaxTime(d time.Duration) Aggregate

	MaxAwaitTime(d time.Duration) Aggregate

	One(result interface{}) error

	All(result interface{}) error

	Cursor() Cursor
}

type ArrayFilters

type ArrayFilters = options.ArrayFilters

type Bulk

type Bulk interface {
	Ordered(ordered bool) Bulk

	BypassDocumentValidation(bypass bool) Bulk

	AddModel(m WriteModel) Bulk

	InsertOne(document interface{}) Bulk

	InsertOneNx(filter interface{}, document interface{}) Bulk

	RepsertOne(filter interface{}, replacement interface{}) Bulk

	ReplaceOne(filter interface{}, replacement interface{}) Bulk

	UpsertOne(filter interface{}, update interface{}) Bulk

	UpsertId(id interface{}, update interface{}) Bulk

	Upsert(filter interface{}, update interface{}) Bulk

	UpdateOne(filter interface{}, update interface{}) Bulk

	UpdateId(id interface{}, update interface{}) Bulk

	UpdateMany(filter interface{}, update interface{}) Bulk

	DeleteOne(filter interface{}) Bulk

	DeleteId(id interface{}) Bulk

	DeleteMany(filter interface{}) Bulk

	Apply(ctx context.Context) (*BulkResult, error)
}

type BulkResult

type BulkResult = mongo.BulkWriteResult

type ChangeEvent

type ChangeEvent struct {
	Id            EventId       `bson:"_id"`
	OperationType OperationType `bson:"operationType"`
	ClusterTime   Timestamp     `bson:"clusterTime"`
	Namespace     Namespace     `bson:"ns"`
	WallTime      DateTime      `bson:"wallTime"`
	DocumentKey   DocumentKey   `bson:"documentKey"`
}

type ChangeStream added in v0.0.12

type ChangeStream = mongo.ChangeStream

type ChangeStreamOptions added in v0.0.12

type ChangeStreamOptions = options.ChangeStreamOptions

func NewChangeStreamOptions added in v0.0.12

func NewChangeStreamOptions() *ChangeStreamOptions

type Client

type Client interface {
	Client() *mongo.Client

	Registry() *bsoncodec.Registry

	Close(ctx context.Context) error

	Ping(ctx context.Context) error

	ServerStatus(ctx context.Context) (bson.Raw, error)

	ServerVersion() string

	TransactionAllowed() bool

	Database(name string, opts ...*DatabaseOptions) Database

	UseSession(ctx context.Context, fn func(SessionContext) error) error

	UseSessionWithOptions(ctx context.Context, opts *options.SessionOptions, fn func(SessionContext) error) error

	StartSession(opts ...*SessionOptions) (Session, error)

	BeginTx(ctx context.Context, opts ...*TransactionOptions) (Tx, error)

	Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*ChangeStream, error)
}

func New

func New(ctx context.Context, cfg *Config) (Client, error)

type Collation

type Collation = options.Collation

type Collection

type Collection interface {
	Database() Database

	Collection() *mongo.Collection

	Name() string

	Drop(ctx context.Context) error

	Clone(opts ...*CollectionOptions) (Collection, error)

	IndexView() IndexView

	InsertOne(ctx context.Context, document interface{}, opts ...*InsertOneOptions) (*InsertOneResult, error)

	InsertOneNx(ctx context.Context, filter interface{}, document interface{}, opts ...*UpdateOptions) (*UpdateResult, error)

	InsertMany(ctx context.Context, documents []interface{}, opts ...*InsertManyOptions) (*InsertManyResult, error)

	Insert(ctx context.Context, documents ...interface{}) (*InsertManyResult, error)

	RepsertOne(ctx context.Context, filter interface{}, replacement interface{}, opts ...*ReplaceOptions) (*UpdateResult, error)

	ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, opts ...*ReplaceOptions) (*UpdateResult, error)

	UpsertOne(ctx context.Context, filter interface{}, update interface{}, opts ...*UpdateOptions) (*UpdateResult, error)

	UpsertId(ctx context.Context, id interface{}, update interface{}, opts ...*UpdateOptions) (*UpdateResult, error)

	Upsert(ctx context.Context, filter interface{}, update interface{}, opts ...*UpdateOptions) (*UpdateResult, error)

	UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*UpdateOptions) (*UpdateResult, error)

	UpdateId(ctx context.Context, id interface{}, update interface{}, opts ...*UpdateOptions) (*UpdateResult, error)

	UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*UpdateOptions) (*UpdateResult, error)

	DeleteOne(ctx context.Context, filter interface{}, opts ...*DeleteOptions) (*DeleteResult, error)

	DeleteId(ctx context.Context, id interface{}, opts ...*DeleteOptions) (*DeleteResult, error)

	DeleteMany(ctx context.Context, filter interface{}, opts ...*DeleteOptions) (*DeleteResult, error)

	Find(ctx context.Context, filter interface{}) Query

	FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}) FindUpdate

	FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}) FindReplace

	FindOneAndDelete(ctx context.Context, filter interface{}) FindDelete

	Bulk() Bulk

	Distinct(ctx context.Context, fieldName string, filter interface{}) Distinct

	Aggregate(ctx context.Context, pipeline interface{}) Aggregate

	Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*ChangeStream, error)
}

type CollectionOptions

type CollectionOptions = options.CollectionOptions

func NewCollectionOptions

func NewCollectionOptions() *CollectionOptions

type Config

type Config struct {
	*options.ClientOptions
}

func NewConfig

func NewConfig(uri string) *Config

type Cursor

type Cursor interface {
	ID() int64

	Next(ctx context.Context) bool

	TryNext(ctx context.Context) bool

	One(result interface{}) error

	All(ctx context.Context, result interface{}) error

	RemainingBatchLength() int

	Close(ctx context.Context) error

	Error() error
}

type CursorType

type CursorType = options.CursorType

type D

type D = bson.D

D is an ordered representation of a BSON document.

func ND

func ND(items ...E) D

type Database

type Database interface {
	Client() Client

	Database() *mongo.Database

	Name() string

	Drop(ctx context.Context) error

	Collection(name string, opts ...*CollectionOptions) Collection

	UseSession(ctx context.Context, fn func(SessionContext) error) error

	UseSessionWithOptions(ctx context.Context, opts *options.SessionOptions, fn func(SessionContext) error) error

	StartSession(opts ...*SessionOptions) (Session, error)

	BeginTx(ctx context.Context, opts ...*TransactionOptions) (Tx, error)

	Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*ChangeStream, error)
}

type DatabaseOptions

type DatabaseOptions = options.DatabaseOptions

func NewDatabaseOptions

func NewDatabaseOptions() *DatabaseOptions

type DateTime

type DateTime = primitive.DateTime

type Decimal128

type Decimal128 = primitive.Decimal128

func NewDecimal128

func NewDecimal128(h, l uint64) Decimal128

type DeleteManyModel

type DeleteManyModel = mongo.DeleteManyModel

func NewDeleteManyModel

func NewDeleteManyModel() *DeleteManyModel

type DeleteOneModel

type DeleteOneModel = mongo.DeleteOneModel

func NewDeleteOneModel

func NewDeleteOneModel() *DeleteOneModel

type DeleteOptions

type DeleteOptions = options.DeleteOptions

func NewDeleteOptions

func NewDeleteOptions() *DeleteOptions

type DeleteResult

type DeleteResult = mongo.DeleteResult

type Distinct

type Distinct interface {
	Collation(c *Collation) Distinct

	MaxTime(d time.Duration) Distinct

	Apply(result interface{}) error
}

type DocumentKey added in v0.0.12

type DocumentKey struct {
	Id string `bson:"_id"`
}

type E

type E = bson.E

E represents a BSON element for a D. It is usually used inside a D.

func NE

func NE(key string, value interface{}) E

type EventId

type EventId struct {
	Data string `bson:"_data"`
}

type FindDelete

type FindDelete interface {
	Collation(c *Collation) FindDelete

	MaxTime(d time.Duration) FindDelete

	Project(projection interface{}) FindDelete

	Sort(fields ...string) FindDelete

	Hint(hint interface{}) FindDelete

	Apply(result interface{}) error
}

type FindReplace

type FindReplace interface {
	BypassDocumentValidation(b bool) FindReplace

	Collation(c *Collation) FindReplace

	MaxTime(d time.Duration) FindReplace

	Project(projection interface{}) FindReplace

	ReturnDocument(rd ReturnDocument) FindReplace

	Sort(fields ...string) FindReplace

	Upsert(b bool) FindReplace

	Hint(hint interface{}) FindReplace

	Apply(result interface{}) error
}

type FindUpdate

type FindUpdate interface {
	ArrayFilters(filters ArrayFilters) FindUpdate

	BypassDocumentValidation(b bool) FindUpdate

	Collation(c *Collation) FindUpdate

	MaxTime(d time.Duration) FindUpdate

	Project(projection interface{}) FindUpdate

	ReturnDocument(rd ReturnDocument) FindUpdate

	Sort(fields ...string) FindUpdate

	Upsert(b bool) FindUpdate

	Hint(hint interface{}) FindUpdate

	Apply(result interface{}) error
}

type FullDocument

type FullDocument = options.FullDocument

type IndexOptions

type IndexOptions = options.IndexOptions

func NewIndexOptions

func NewIndexOptions() *IndexOptions

type IndexView

type IndexView interface {
	IndexView() mongo.IndexView

	Create(ctx context.Context, keys []string, opts *IndexOptions) (string, error)

	CreateIndex(ctx context.Context, name string, keys []string) (string, error)

	CreateUniqueIndex(ctx context.Context, name string, keys []string) (string, error)

	CreateTTLIndex(ctx context.Context, name string, keys []string, ttl int32) (string, error)

	DropIndex(ctx context.Context, keys []string) error

	Drop(ctx context.Context, name string) error

	DropAll(ctx context.Context) error
}

type InsertManyOptions

type InsertManyOptions = options.InsertManyOptions

func NewInsertManyOptions

func NewInsertManyOptions() *InsertManyOptions

type InsertManyResult

type InsertManyResult = mongo.InsertManyResult

type InsertOneModel

type InsertOneModel = mongo.InsertOneModel

func NewInsertOneModel

func NewInsertOneModel() *InsertOneModel

type InsertOneOptions

type InsertOneOptions = options.InsertOneOptions

func NewInsertOneOptions

func NewInsertOneOptions() *InsertOneOptions

type InsertOneResult

type InsertOneResult = mongo.InsertOneResult

type M

type M = bson.M

M is an unordered representation of a BSON document.

type Namespace

type Namespace struct {
	Database   string `bson:"db"`
	Collection string `bson:"coll"`
}

type Null

type Null = primitive.Null

type ObjectId

type ObjectId = primitive.ObjectID

func MustObjectId

func MustObjectId(s string) ObjectId

func NewObjectId

func NewObjectId() ObjectId

func NewObjectIdFromTime

func NewObjectIdFromTime(t time.Time) ObjectId

func ObjectIdFromHex

func ObjectIdFromHex(s string) (ObjectId, error)

type OperationType

type OperationType string

type Pipeline

type Pipeline = mongo.Pipeline

func NP

func NP(items ...D) Pipeline

type Query

type Query interface {
	BatchSize(n int32) Query

	Hint(hint interface{}) Query

	Limit(n int64) Query

	Project(projection interface{}) Query
	Select(projection interface{}) Query

	Skip(n int64) Query

	Sort(fields ...string) Query

	AllowDiskUse(b bool) Query

	AllowPartialResults(b bool) Query

	Collation(c *Collation) Query

	Comment(s string) Query

	CursorType(cursorType CursorType) Query

	Max(m interface{}) Query

	MaxAwaitTime(d time.Duration) Query

	MaxTime(d time.Duration) Query

	Min(m interface{}) Query

	NoCursorTimeout(b bool) Query

	ReturnKey(b bool) Query

	ShowRecordId(b bool) Query

	One(result interface{}) error

	All(result interface{}) error

	Count() (int64, error)

	Cursor() Cursor
}

type Raw

type Raw = bson.Raw

type Regex

type Regex = primitive.Regex

func NR

func NR(pattern, options string) Regex

type ReplaceOneModel

type ReplaceOneModel = mongo.ReplaceOneModel

func NewReplaceOneModel

func NewReplaceOneModel() *ReplaceOneModel

type ReplaceOptions

type ReplaceOptions = options.ReplaceOptions

func NewReplaceOptions

func NewReplaceOptions() *ReplaceOptions

type ReturnDocument

type ReturnDocument = options.ReturnDocument

type Session

type Session interface {
	mongo.Session

	BeginTx(ctx context.Context, opts ...*TransactionOptions) (Tx, error)
}

type SessionContext

type SessionContext = mongo.SessionContext

type SessionOptions

type SessionOptions = options.SessionOptions

func NewSessionOptions

func NewSessionOptions() *SessionOptions

type Timestamp

type Timestamp = primitive.Timestamp

type TransactionOptions

type TransactionOptions = options.TransactionOptions

func NewTransactionOptions

func NewTransactionOptions() *TransactionOptions

type Tx added in v0.0.12

type Tx interface {
	context.Context

	Commit(ctx context.Context) error

	Rollback(ctx context.Context) error
}

type UpdateManyModel

type UpdateManyModel = mongo.UpdateManyModel

func NewUpdateManyModel

func NewUpdateManyModel() *UpdateManyModel

type UpdateOneModel

type UpdateOneModel = mongo.UpdateOneModel

func NewUpdateOneModel

func NewUpdateOneModel() *UpdateOneModel

type UpdateOptions

type UpdateOptions = options.UpdateOptions

func NewUpdateOptions

func NewUpdateOptions() *UpdateOptions

type UpdateResult

type UpdateResult = mongo.UpdateResult

type WriteModel

type WriteModel = mongo.WriteModel

Directories

Path Synopsis
examples module

Jump to

Keyboard shortcuts

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