bsonquery

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: MIT Imports: 2 Imported by: 0

README

bsonquery

bson query builder for official mongodb driver for golang

Installation

go get github.com/samtech09/bsonquery

Usage

First import package

import bq github.com/samtech09/bsonquery

Create and build query

// filter to query data
filter := bq.Builder().
		And(bq.C().EQ("name", "test2"), bq.C().GT("age", 29)).
		Build()

// Find documents by running filer on collection
cur, err := coll.Find(context.Background(), filter)
...

Use bq.And(...) for querying one or more fields.

Supported Operators

Logical operators
bsonquery Function equivalent operator
bq.And $and
bq.Or $or
bq.Not $not
bq.Nor $nor
Conditional and Other
bsonquery Condition equivalent operator
bq.C().EQ $eq
bq.C().GT $gt
bq.C().GTE $gte
bq.C().IN $in
bq.C().LT $lt
bq.C().LTE $lte
bq.C().NE $ne
bq.C().NIN $nin
bq.C().Regex $regex
bq.C().Exist $exists


Feedback and suggestions are welcomed.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Builder

func Builder() *builder

func C

func C() *condition

C creates a new Condition

Types

This section is empty.

Jump to

Keyboard shortcuts

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