Browse Source

Create custom name mapping with TableName interface or struct tags.

Frederic G. MARAND 9 năm trước cách đây
mục cha
commit
ddb7ef5985
1 tập tin đã thay đổi với 12 bổ sung0 xóa
  1. 12 0
      main.go

+ 12 - 0
main.go

@@ -29,6 +29,18 @@ import (
 	"github.com/go-xorm/core"
 )
 
+type Foo struct {
+	Baz string `xorm:`
+}
+
+// Implement the TableName interface to generate a fully custom table name for
+// a struct type.
+//
+// @see xorm.TableName interface.
+func (f Foo) TableName() string {
+	return "foobar";
+}
+
 func check(err error) {
 	if err != nil {
 		fmt.Println(err.Error())