Skip to content

ahamidi/haigo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Circle CI GoDoc

Haigo

YeSQL-like abstraction layer for Mongo on Go

What is Haigo?

Haigo lets you write and use standard MongoDB queries directly from within your Go application.

Why?

While working on a project that leveraged Mongo's aggregation framework extensively, we found that writing complicated queries in Go was painful and brittle with deeply nested bson.M or map[string]interface{} clauses.

With Haigo, you can use the JSON formatted Mongo queries directly.

Usage

  1. Connect to Mongo (as you would normally)

  2. Load Query File: SEE examples/queries.yml for example query files.
    hf, err := haigo.LoadQueryFile("queries.yml")

  3. Configure Haigo Params:
    params := haigo.Params{"name": "Ali", "age": 32}

  4. Execute Query/Pipe:
    q, err := hf.Queries["FindUser"].Pipe(col, params)

  5. Handle result (as you would normally):
    q.Count()

TODO

  • Parse MongoDB Query YAML
  • Detect Queries
  • Replace Query Params
  • Integrate CI
  • More/Better Tests
  • Better Error Handling

About

YeSQL-like abstraction layer for Mongo on Go

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages