sdbc/README.md
2023-09-11 00:13:23 +08:00

715 B

sdbc

sdbc: sqlite database connector

项目命名为sdbc 一个sqlite数据库orm,对官方驱动进行封装,将protobuf的Message和sqlite的Model进行绑定,实现对Message的操作可以同步到数据库中

todo

  • 完成初始化程序
  • 封装CRUD

usage

package main

import (
	"time"
	
    "gitter.top/drivers/sdbc"
)

func main() {
	var driver = NewSDBC(&Config{
		Dbname:      "test.db",
		MaxIdleConn: 10,
		MaxOpenConn: 100,
		MaxLifetime: time.Hour,
	}).BindModel(&ModelArticles{})

	var doc = &ModelArticles{
		Title:      "hello world",
		CreateTime: time.Now().Unix(),
	}
	err = driver.Insert().InsertOne(doc)
	assert.NoError(t, err)
	t.Logf("doc id: %v", doc.Id)
}