func (db *Database) First(dest DBModel, key interface{}) error {
	modelKey, _ := primaryKey(dest)
	in := reflect.Indirect(reflect.ValueOf(dest))
	in.FieldByName(modelKey).Set(reflect.Indirect(reflect.ValueOf(key)))
	return db.Model(dest).Where(in.Interface()).Scan(dest)
}
First Scans the result of the selection query of type model using the specified id
Panics if key is not compatible with the primary key filed type or if the query formulation fails
package igor
import (
	"bytes"
	"database/sql"
	"errors"
	"fmt"
	"log"
	"reflect"
	"sort"
	"strings"
	_ "github.com/lib/pq"
)
func Connect(connectionString string) (*Database, error) {
	var e error
	db := new(Database)
	if db.db, e = sql.Open("postgres", connectionString); e != nil {
		return nil, e
	}
	if e = db.DB().Ping(); e != nil {
		return nil, errors.New("Connection failed. Unable to ping the DB: " + e.Error())
	}
	db.connectionString = connectionString
	db.clear()
	return db, nil
}
func (db *Database) Log(logger *log.Logger) *Database {
	db.logger = logger
	return db
}
func (db *Database) Model(model DBModel) *Database {
	db = db.clone()
	db.tables = append(db.tables, handleIdentifier(model.TableName()))
	db.models = append(db.models, model)
	return db
}
func (db *Database) Joins(joins string) *Database {
	db = db.clone()
	db.joinTables = append(db.joinTables, joins)
	return db
}
func (db *Database) Table(table string) *Database {
	db = db.clone()
	db.tables = append(db.tables, handleIdentifier(table))
	return db
}
func (db *Database) Select(fields string, args ...interface{}) *Database {
	db = db.clone()
	db.selectFields += db.replaceMarks(fields)
	db.cteSelectValues = append(db.cteSelectValues, args...)
	return db
}
func (db *Database) CTE(cte string, args ...interface{}) *Database {
	db = db.clone()
	db.cte += db.replaceMarks(cte)
	db.cteSelectValues = append(db.cteSelectValues, args...)
	return db
}
func (db *Database) Delete(value DBModel) error {
	defer db.clear()
	if len(db.tables) == 0 {
		db.tables = append(db.tables, handleIdentifier(value.TableName()))
		db.models = append(db.models, value)
	}
	db = db.Where(value)
	var stmt *sql.Stmt
	var err error
	if stmt, err = db.db.Prepare(db.buildDelete()); err != nil {
		return err
	}
	defer stmt.Close()
	if _, err = stmt.Exec(db.whereValues...); err != nil {
		return err
	}
	value = reflect.Zero(reflect.ValueOf(value).Type()).Interface().(DBModel)
	return nil
}
func (db *Database) Updates(value DBModel) error {
	defer func() {
		if db.rawRows != nil {
			db.rawRows.Close()
		}
	}()
	clone := db.Where(value)
	return clone.commonCreateUpdate(value, clone.buildUpdate)
}
func (db *Database) Create(value DBModel) error {
	defer func() {
		if db.rawRows != nil {
			db.rawRows.Close()
		}
	}()
	db = db.clone()
	return db.commonCreateUpdate(value, db.buildCreate)
}
func (db *Database) Pluck(column string, slice interface{}) error {
	dest := reflect.Indirect(reflect.ValueOf(slice))
	if dest.Kind() != reflect.Slice {
		db.panicLog(fmt.Sprintf("slice should be a slice, not %s\n", dest.Kind()))
	}
	db = db.Select(column)
	return db.Scan(slice)
}
func (db *Database) Count(value *uint8) error {
	key, _ := primaryKey(db.models[0])
	if key != "" {
		db = db.Select("count(" + handleIdentifier(key) + ")")
	} else {
		db = db.Select("count(*)")
	}
	return db.Scan(value)
}