filter

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BSONType

type BSONType int

BSONType represents BSON type constants for type checking

const (
	BSONTypeDouble     BSONType = 1
	BSONTypeString     BSONType = 2
	BSONTypeObject     BSONType = 3
	BSONTypeArray      BSONType = 4
	BSONTypeBinary     BSONType = 5
	BSONTypeObjectID   BSONType = 7
	BSONTypeBoolean    BSONType = 8
	BSONTypeDateTime   BSONType = 9
	BSONTypeNull       BSONType = 10
	BSONTypeRegex      BSONType = 11
	BSONTypeJavaScript BSONType = 13
	BSONTypeInt32      BSONType = 16
	BSONTypeTimestamp  BSONType = 17
	BSONTypeInt64      BSONType = 18
	BSONTypeDecimal128 BSONType = 19
)

type Builder

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

Builder represents a fluent filter builder for MongoDB queries

func All

func All(field string, values ...any) *Builder

All creates a filter that matches arrays containing all specified values

func And

func And(filters ...*Builder) *Builder

Convenience function for And that can be called statically

func ElemMatch

func ElemMatch(field string, filter *Builder) *Builder

ElemMatch creates an element match filter for arrays

func Eq

func Eq(field string, value any) *Builder

Eq creates an equality filter

func Exists

func Exists(field string, exists bool) *Builder

Exists creates a filter for field existence

func Gt

func Gt(field string, value any) *Builder

Gt creates a greater-than filter

func Gte

func Gte(field string, value any) *Builder

Gte creates a greater-than-or-equal filter

func In

func In(field string, values ...any) *Builder

In creates an "in" filter for array membership

func Lt

func Lt(field string, value any) *Builder

Lt creates a less-than filter

func Lte

func Lte(field string, value any) *Builder

Lte creates a less-than-or-equal filter

func Ne

func Ne(field string, value any) *Builder

Ne creates a not-equal filter

func New

func New() *Builder

New creates a new filter builder

func Nin

func Nin(field string, values ...any) *Builder

Nin creates a "not in" filter for array non-membership

func Or

func Or(filters ...*Builder) *Builder

Convenience function for Or that can be called statically

func Regex

func Regex(field string, pattern string, options ...string) *Builder

Regex creates a regular expression filter

func Size

func Size(field string, size int) *Builder

Size creates a filter for array size

func Text

func Text(query string) *Builder

Text creates a text search filter

func Type

func Type(field string, bsonType BSONType) *Builder

Type creates a filter for BSON type checking

func (*Builder) And

func (b *Builder) And(filters ...*Builder) *Builder

And combines multiple filters with logical AND

func (*Builder) Build

func (b *Builder) Build() bson.M

Build returns the underlying BSON filter document

func (*Builder) Not

func (b *Builder) Not() *Builder

Not negates the current filter

func (*Builder) Or

func (b *Builder) Or(filters ...*Builder) *Builder

Or combines multiple filters with logical OR

func (*Builder) ToBSONM

func (b *Builder) ToBSONM() bson.M

ToBSONM converts the filter to a bson.M for compatibility

Jump to

Keyboard shortcuts

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