Skip to content

worg/meth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

METH

M​aladroit E​lusive T​ransaction H​ub

A wrapper around upper.io/db to ease some repetitive tasks.

Reasoning Behind

Working with upper.io/db sometimes becomes a little bit repetitive, so METH is an attempt to minimize the scaffolding needed in some basic tasks [fetching by id, by certain conditions].

Badges

GoDoc Build Status Go Report Card

Usage

Install

go get github.com/worg/meth

Any type must implement Persistent interface and return an initalized and valid db.Collection in order to use METH functions.

Example

package person

import (
    "upper.io/db"
    "upper.io/db/some_driver"
    
)

type Person struct {
    ID      int    `db:"id"`
    Name    string `db:"name"`
    Address string `db:"address"`
}

var (
    collection db.Collection
)

func init() {
    //init DB and set collection
}

func (p *Person) Collection() db.Collection {
    return collection
}

func (p *Person) ById(id int) {
    if err := meth.One(&p); err := nil {
        // handle err
    }
    // by this point p should've been filled with db data
}

About

Maladroit Elusive Transaction Hub

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages