condition

package
v0.0.0-...-6524a5b Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pipe

func Pipe(stage ...Condition) bson.M

The condition.Pipe differs from the aggregate.Pipe in that it doesn't produce a slice (bson.A) as it's output value, rather it produces a map (bson.M). This is because MongoDB queries use objects whereas the collection.aggregate function takes an array.

Types

type Condition

type Condition struct {
	Key   string
	Value interface{}
}

Used in most condition operators. The Key is used to specify the field in the collection that is being queried and the value is the query itself. This query could be a new condition.Pipe

func BoolMatch

func BoolMatch(c Condition) Condition

Uses the $eq operator to filter on a matching bool value in a MongoDB document.

func DateGreaterThanOrEqualTo

func DateGreaterThanOrEqualTo(c Condition) Condition

Uses the $gte operator and the time.Parse function to filter documents where the document provided field is greater than or equal to the specified field.

func DateLessThanOrEqualTo

func DateLessThanOrEqualTo(c Condition) Condition

Uses the $lte operator and the time.Parse function to filter documents where the document provided field is less than or equal to the specified field.

func ElemMatch

func ElemMatch(c Condition) Condition

Uses the $elemMatch operator to matche documents that contain an array field with at least one element that matches all the specified query criteria.

func EqualTo

func EqualTo(c Condition) Condition

Uses the $eq operator to find a matching value of any type in a MongoDB document.

func InArray

func InArray(c Condition) Condition

Uses the $in operator to check if a value exists in an array in a MongoDB document.

func NotEqualTo

func NotEqualTo(c Condition) Condition

Uses the $ne operator to filter values that do not match the provided value of any type in a MongoDB document.

func NumberMatch

func NumberMatch(c Condition) Condition

Uses the $eq operator to filter on a matching number value in a MongoDB document.

func ObjectIdMatch

func ObjectIdMatch(c Condition) Condition

Uses the $eq operator and the util.StringToObjectId function to find a matching ObjectID in a MongoDB document.

func StringEndsWith

func StringEndsWith(c Condition) Condition

Uses the $regex operator to match a string that ends with the provided string in a MongoDB document.

func StringLike

func StringLike(c Condition) Condition

Uses the $regex operator to match any part of a string in a MongoDB document.

func StringMatch

func StringMatch(c Condition) Condition

Uses the $regex operator to match a whole string in a MongoDB document.

func StringStartsWith

func StringStartsWith(c Condition) Condition

Uses the $regex operator to match a string that starts with the provided string in a MongoDB document.

type ConditionOperation

type ConditionOperation bson.M

The ConditionOperation is a simple type alias for the bson.M type and allows for more simple conversions

Jump to

Keyboard shortcuts

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