diff --git a/main.go b/main.go new file mode 100644 index 00000000..f271a233 --- /dev/null +++ b/main.go @@ -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 +} diff --git a/orm.go b/orm.go new file mode 100644 index 00000000..d03849b6 --- /dev/null +++ b/orm.go @@ -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 +} diff --git a/utils.go b/utils.go new file mode 100644 index 00000000..4506bcfe --- /dev/null +++ b/utils.go @@ -0,0 +1 @@ +package gorm