github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/models/database.go (about)

     1  package models
     2  
     3  import (
     4  	"database/sql/driver"
     5  
     6  	"github.com/machinefi/w3bstream/pkg/depends/kit/sqlx"
     7  	"github.com/machinefi/w3bstream/pkg/depends/kit/sqlx/datatypes"
     8  )
     9  
    10  var (
    11  	DB        = sqlx.NewDatabase("demo").WithSchema("applet_management")
    12  	MonitorDB = sqlx.NewDatabase("demo").WithSchema("monitor")
    13  	WasmDB    = sqlx.NewDatabase("wasm_storage")
    14  )
    15  
    16  type Meta map[string]string
    17  
    18  func (Meta) DataType(driver string) string { return "text" }
    19  
    20  func (m Meta) Value() (driver.Value, error) { return datatypes.JSONValue(m) }
    21  
    22  func (m *Meta) Scan(src interface{}) error { return datatypes.JSONScan(src, m) }
    23  
    24  type Text string
    25  
    26  func (Text) Datatype(driver string) string { return "text" }