init files

This commit is contained in:
Jinzhu 2013-10-25 18:04:48 +08:00
parent 69d8c85375
commit 2d6fa2c96d
3 changed files with 149 additions and 0 deletions

83
main.go Normal file
View File

@ -0,0 +1,83 @@
package gorm
import "database/sql"
type DB struct {
Db *sql.DB
}
func Open(driver, source string) (db *DB, err error) {
db.Db, err = sql.Open(driver, source)
return
}
func (s *DB) buildORM() (orm *Orm, err error) {
orm.Db = s.Db
return
}
func (s *DB) Where(querystring interface{}, args ...interface{}) (orm *Orm, err error) {
orm, err = s.buildORM()
orm.Where(querystring, args)
return
}
func (s *DB) First() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Find() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Limit() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Offset() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Order() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Or() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Not() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Count() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Select() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Save() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Delete() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}
func (s *DB) Exec() (orm *Orm, err error) {
orm, err = s.buildORM()
return
}

65
orm.go Normal file
View File

@ -0,0 +1,65 @@
package gorm
import "database/sql"
type Orm struct {
Db *sql.DB
TableName string
WhereStr string
OrderStr string
PrimaryKey string
OffsetInt int64
LimitInt int64
}
func (s *Orm) Where(querystring interface{}, args ...interface{}) (*Orm, error) {
return s, nil
}
func (s *Orm) First() (*Orm, error) {
return s, nil
}
func (s *Orm) Find() (*Orm, error) {
return s, nil
}
func (s *Orm) Limit() (*Orm, error) {
return s, nil
}
func (s *Orm) Offset() (*Orm, error) {
return s, nil
}
func (s *Orm) Order() (*Orm, error) {
return s, nil
}
func (s *Orm) Or() (*Orm, error) {
return s, nil
}
func (s *Orm) Not() (*Orm, error) {
return s, nil
}
func (s *Orm) Count() (*Orm, error) {
return s, nil
}
func (s *Orm) Select() (*Orm, error) {
return s, nil
}
func (s *Orm) Save() (*Orm, error) {
return s, nil
}
func (s *Orm) Delete() (*Orm, error) {
return s, nil
}
func (s *Orm) Exec() (*Orm, error) {
return s, nil
}

1
utils.go Normal file
View File

@ -0,0 +1 @@
package gorm