From a2c593885a0e705cccc36bd0d6a662cad0f36d33 Mon Sep 17 00:00:00 2001 From: xing Date: Sun, 28 Aug 2022 22:03:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 4 ++-- models/model.go | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 3b1b32e..7ba3804 100644 --- a/main.go +++ b/main.go @@ -19,9 +19,9 @@ func init() { } func main() { - T, total, err := models.WpPostsM.SimplePagination(nil, "*", 1, 10, models.SqlBuilder{{"ID", "desc"}}) + T, err := models.WpPostsM.FindOneById(1) if err != nil { return } - fmt.Println(T, total) + fmt.Println(T) } diff --git a/models/model.go b/models/model.go index 137714e..d5a4916 100644 --- a/models/model.go +++ b/models/model.go @@ -15,6 +15,14 @@ type mod interface { type model[T mod] struct { } +func (m model[T]) PrimaryKey() string { + return "id" +} + +func (m model[T]) Table() string { + return "" +} + type SqlBuilder [][]string func (w SqlBuilder) parseWhere() (string, []interface{}) {