cworm

package module
v0.0.0-...-85840d5 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 14 Imported by: 0

README

cwORM – GoLang ORM

Under development. cwORM was created for CWBlog. cwORM is a free and open source ORM.

Under Development MIT License Go Report Card GoDoc

Features
  • DB Migrations
  • Basic ORM
  • MySQL
  • PostgreSQL
  • SQLite
Roadmap:
  • Documentation (coming soon)
To-do:
  • Refactor "Return" types and come up with a better solution to "reset/clear" Query

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Make

func Make(cmd string, name string) (msg string, err error)

func Migrate

func Migrate(cmd string) (msg string, err error)

Types

type DB

type DB struct {
	*sql.DB
	Query  Query
	Errors []error
}

DB ...

func Connect

func Connect(dialect string, username string, password string, host string, port string, database string) (worm *DB, err error)

Connect establishes a new database connection

func (*DB) Delete

func (db *DB) Delete(Model interface{}) (int64, error)

Delete ...

func (*DB) Error

func (db *DB) Error(err error)

func (*DB) ErrorMessages

func (db *DB) ErrorMessages() error

ErrorMessages ...

func (*DB) Exists

func (db *DB) Exists(Model interface{}) (exists bool, err error)

Exists ...

func (*DB) First

func (db *DB) First(Model interface{}) error

First ...

func (*DB) Get

func (db *DB) Get(Model interface{}) ([]interface{}, error)

Get ...

func (*DB) GroupBy

func (db *DB) GroupBy(columns ...string) *DB

GroupBy ...

func (*DB) HasErrors

func (db *DB) HasErrors() bool

HasErrors ...

func (*DB) Insert

func (db *DB) Insert(Model interface{}) (interface{}, error)

Insert ...

func (*DB) Join

func (db *DB) Join(models ...interface{}) *DB

Join ...

func (*DB) Limit

func (db *DB) Limit(limit int) *DB

Limit ...

func (*DB) New

func (db *DB) New(Model interface{}) (interface{}, error)

New ...

func (*DB) Offset

func (db *DB) Offset(offset int) *DB

Offset ...

func (*DB) OrderBy

func (db *DB) OrderBy(column string, order string) *DB

OrderBy ...

func (*DB) ResetQuery

func (db *DB) ResetQuery()

ResetQuery ...

func (*DB) Return

func (db *DB) Return(resp interface{}, err error) (interface{}, error)

Return – TODO: Refactor to not use return functions to reset query.

func (*DB) ReturnBool

func (db *DB) ReturnBool(resp bool, err error) (bool, error)

ReturnBool – TODO: Refactor to not use return functions to reset query.

func (*DB) ReturnError

func (db *DB) ReturnError(err error) error

ReturnError – TODO: Refactor to not use return functions to reset query.

func (*DB) ReturnGroup

func (db *DB) ReturnGroup(resp []interface{}, err error) ([]interface{}, error)

ReturnGroup – TODO: Refactor to not use return functions to reset query.

func (*DB) ReturnInt64

func (db *DB) ReturnInt64(resp int64, err error) (int64, error)

ReturnInt64 – TODO: Refactor to not use return functions to reset query.

func (*DB) Save

func (db *DB) Save(Model interface{}) error

Save ...

func (*DB) Select

func (db *DB) Select(columns ...string) *DB

Select ...

func (*DB) Where

func (db *DB) Where(column string, operator string, value interface{}) *DB

Where ...

type Query

type Query struct {
	Columns []string
	Params  []string
	Values  []interface{}
	Args    []interface{}

	Select  string
	Where   string
	Join    string
	GroupBy string
	Having  string
	OrderBy string
	Limit   string
	Offset  string

	Table      string
	Conditions []interface{}
	Joins      []interface{}

	Model reflect.Value
}

Query ...

func (*Query) BuildConditions

func (query *Query) BuildConditions() error

BuildConditions ...

func (*Query) BuildDelete

func (query *Query) BuildDelete() (sql string, args []interface{}, err error)

BuildDelete ...

func (*Query) BuildInsert

func (query *Query) BuildInsert() (sql string, err error)

BuildInsert ...

func (*Query) BuildJoin

func (query *Query) BuildJoin(Model interface{}) error

BuildJoin ...

func (*Query) BuildSelect

func (query *Query) BuildSelect() (sql string, err error)

BuildSelect ...

func (*Query) BuildUpdate

func (query *Query) BuildUpdate() (sql string, args []interface{}, err error)

BuildUpdate ...

type Where

type Where struct {
	Column   string
	Operator string
	Value    interface{}
}

Where ...

Jump to

Keyboard shortcuts

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