Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.29 KB

README.md

File metadata and controls

42 lines (29 loc) · 1.29 KB

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