remove function From for package gdb; add function g.Table; add ServeHTTP interface implements for ghttp.Server

This commit is contained in:
John
2020-04-04 22:46:52 +08:00
parent ccceeae29c
commit 2d30a53c3a
10 changed files with 50 additions and 30 deletions

View File

@ -78,8 +78,8 @@ type DB interface {
Delete(table string, condition interface{}, args ...interface{}) (sql.Result, error)
// Model creation.
From(tables string) *Model
Table(tables string) *Model
Model(tables string) *Model
Schema(schema string) *Schema
// Configuration methods.

View File

@ -69,7 +69,6 @@ func (c *Core) Table(table string) *Model {
fields: "*",
start: -1,
offset: -1,
safe: true,
option: OPTION_ALLOWEMPTY,
}
}
@ -80,13 +79,6 @@ func (c *Core) Model(table string) *Model {
return c.DB.Table(table)
}
// From is alias of Core.Table.
// See Core.Table.
// Deprecated.
func (c *Core) From(table string) *Model {
return c.DB.Table(table)
}
// Table acts like Core.Table except it operates on transaction.
// See Core.Table.
func (tx *TX) Table(table string) *Model {
@ -99,7 +91,6 @@ func (tx *TX) Table(table string) *Model {
fields: "*",
start: -1,
offset: -1,
safe: true,
option: OPTION_ALLOWEMPTY,
}
}
@ -110,13 +101,6 @@ func (tx *TX) Model(table string) *Model {
return tx.Table(table)
}
// From is alias of tx.Table.
// See tx.Table.
// Deprecated.
func (tx *TX) From(table string) *Model {
return tx.Table(table)
}
// As sets an alias name for current table.
func (m *Model) As(as string) *Model {
if m.tables != "" {

View File

@ -26,7 +26,7 @@ func Test_Model_Insert(t *testing.T) {
table := createTable()
defer dropTable(table)
gtest.C(t, func(t *gtest.T) {
user := db.From(table)
user := db.Table(table)
result, err := user.Filter().Data(g.Map{
"id": 1,
"uid": 1,

View File

@ -120,7 +120,7 @@ func Test_TX_Insert(t *testing.T) {
if err != nil {
gtest.Error(err)
}
user := tx.From(table)
user := tx.Table(table)
if _, err := user.Data(g.Map{
"id": 1,
"passport": "t1",