8000 GitHub - 7CaD/mo: Pipeline query builder for mongo-go-driver · GitHub
[go: up one dir, main page]

Skip to content
7CaDPublic

About

Pipeline query builder for mongo-go-driver

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

mo

Pipeline query builder designed for mongo-go-driver. It provides a fluent and intuitive interface to construct MongoDB aggregation pipelines in Go.

Usage

go get github.com/7CaD/mo

Example:

package main

import (
    "github.com/7CaD/mo"
    "go.mongodb.org/mongo-driver/bson"

    "context"
)

func main() {
    pipeline := mo.NewPipeline().
        Match(bson.M{"status": "A"}).
        Group(bson.M{"_id": "$cust_id", "total": bson.M{"$sum": "$amount"}}).
        Sort(bson.M{"total": -1}).
        Build()

    // Use 'pipeline' with your mongo-go-driver collection
    collection := client.Database("your_database").Collection("your_collection")
    cursor, err := collection.Aggregate(context.TODO(), pipeline)

    // ...
}

About

Pipeline query builder for mongo-go-driver

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0