coocood/qbs

FindAll get empty

tablecell opened this issue · 0 comments

package main

import (
	"fmt"
	"github.com/coocood/qbs"
	_ "github.com/mattn/go-sqlite3"
	"time"
)

type Book struct {
	Id int64
	Title     string
	Author    string
	Published time.Time
}


func main() {

	qbs.Register("sqlite3", "book.db", "qbs_test", qbs.NewSqlite3())

	q, err := qbs.GetQbs()
 
	migration, err := qbs.GetMigration()

	defer migration.Close()
	err = migration.CreateTableIfNotExists(new(Book))
	fmt.Println(err)

 
	var book = &Book{
		Title:     "new book",
		Author:    "qbs",
		Published: time.Now(),
	}

	out, err := q.Save(book)
 
	fmt.Println(out,err)
 
	var books []*Book
	err = q.Limit(10).Offset(10).FindAll(&books)
	fmt.Println(err)
	for k, v := range books {

		fmt.Println(k, v)
	}
	
/*
sqlite> select * from book;
4|new book|qbs|2021-10-14 07:27:48.3926642+08:00
*/
	

}