mongogen

package module
v0.0.0-...-398997f Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

README

mongogen

mongodb index-based query builder (go:generate + mongodb-go-driver).

install
go get github.com/localmeasure/mongogen
go install github.com/localmeasure/mongogen/mongogen
setup

Declare index specs:

  • Singlefield index: field1:go_type. Example: group_id:int
  • Compound index: field2:go_type+field3:go_type. Example: location_id:id+last_seen:time
  • Multikey index: field4:[]go_type. Example: team_id:[]int

Some common types are supported:

  • id: primitive.ObjectID
  • time: time.Time
examples

Create example.go:

//go:generate mongogen -p users -c users -i group_id:id+name:string -i team_id:id+last_seen:time

Then run (see example output here):

go generate

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

func NewGenerator

func NewGenerator() *Generator

func (*Generator) Gen

func (g *Generator) Gen(pkgName string, collection string, indexes []string)

func (*Generator) Output

func (g *Generator) Output() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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