func (q *Query) Delete() error {
	return q.DeleteAll()
}
Delete one model specified in this relation
package query
import (
	"database/sql"
	"fmt"
	"sort"
	"strconv"
	"strings"
)
var Debug bool
func init() {
	Debug = false  
}
type Result map[string]interface{}
type Func func(q *Query) *Query
type Query struct {
	tablename  string
	primarykey string
	sql    string
	sel    string
	join   string
	where  string
	group  string
	having string
	order  string
	offset string
	limit  string
	args []interface{}
}
func New(t string, pk string) *Query {
	if database == nil {
		return nil
	}
	q := &Query{
		tablename:  t,
		primarykey: pk,
	}
	return q
}
func Exec(sql string, args ...interface{}) (sql.Result, error) {
	results, err := database.Exec(sql, args...)
	return results, err
}
func Rows(sql string, args ...interface{}) (*sql.Rows, error) {
	results, err := database.Query(sql, args...)
	return results, err
}
func (q *Query) Copy() *Query {
	return &Query{
		tablename:  q.tablename,
		primarykey: q.primarykey,
		sql:        q.sql,
		sel:        q.sel,
		join:       q.join,
		where:      q.where,
		group:      q.group,
		having:     q.having,
		order:      q.order,
		offset:     q.offset,
		limit:      q.limit,
		args:       q.args,
	}
}
func (q *Query) InsertJoin(a int64, b int64) error {
	return q.InsertJoins([]int64{a}, []int64{b})
}
func (q *Query) InsertJoins(a []int64, b []int64) error {
	if len(a) == 0 || len(b) == 0 {
		return fmt.Errorf("Null data for joins insert %s", q.table())
	}
	values := ""
	for _, av := range a {
		for _, bv := range b {
			if av != 0 && bv != 0 {
				values += fmt.Sprintf("(%d,%d),", av, bv)
			}
		}
	}
	values = strings.TrimRight(values, ",")
	sql := fmt.Sprintf("INSERT into %s VALUES %s;", q.table(), values)
	if Debug {
		fmt.Printf("JOINS SQL:%s\n", sql)
	}
	_, err := database.Exec(sql)
	return err
}
func (q *Query) UpdateJoins(id int64, a []int64, b []int64) error {
	if Debug {
		fmt.Printf("SetJoins %s %s=%d: %v %v \n", q.table(), q.pk(), id, a, b)
	}
	err := q.Where(fmt.Sprintf("%s=?", q.pk()), id).Delete()
	if err != nil {
		return err
	}
	if len(a) > 0 && len(b) > 0 {
		err = q.InsertJoins(a, b)
		if err != nil {
			return err
		}
	}
	return nil
}
func (q *Query) Insert(params map[string]string) (int64, error) {
	sql := q.insertSQL(params)
	if Debug {
		fmt.Printf("INSERT SQL:%s %v\n", sql, valuesFromParams(params))
	}
	id, err := database.Insert(sql, valuesFromParams(params)...)
	if err != nil {
		return 0, err
	}
	return id, nil
}
func (q *Query) insertSQL(params map[string]string) string {
	var cols, vals []string
	for i, k := range sortedParamKeys(params) {
		cols = append(cols, database.QuoteField(k))
		vals = append(vals, database.Placeholder(i+1))
	}
	query := fmt.Sprintf("INSERT INTO %s (%s) VALUES(%s) %s;", q.table(), strings.Join(cols, ","), strings.Join(vals, ","), database.InsertSQL(q.pk()))
	return query
}
func (q *Query) Update(params map[string]string) error {
	return q.UpdateAll(params)
}