refactor(db): 重命名批量插入方法并更新文档

- 将 BatchInsert 方法重命名为 Inserts,以更好地反映其功能
- 更新示例代码和文档,确保使用新方法名
- 删除过时的文档文件,整合 HoTimeDB 使用说明和 API 参考
- 优化 README.md,增强框架特性和安装说明的清晰度
This commit is contained in:
2026-01-22 20:32:29 +08:00
parent 5235ef133d
commit e704701752
9 changed files with 366 additions and 452 deletions
+7 -7
View File
@@ -44,7 +44,7 @@ func main() {
results["6_pagination"] = testPagination(that)
// 7. 批量插入测试
results["7_batch_insert"] = testBatchInsert(that)
results["7_batch_insert"] = testInserts(that)
// 8. Upsert 测试
results["8_upsert"] = testUpsert(that)
@@ -86,7 +86,7 @@ func main() {
"join": func(that *Context) { that.Display(0, testJoinQuery(that)) },
"aggregate": func(that *Context) { that.Display(0, testAggregate(that)) },
"pagination": func(that *Context) { that.Display(0, testPagination(that)) },
"batch": func(that *Context) { that.Display(0, testBatchInsert(that)) },
"batch": func(that *Context) { that.Display(0, testInserts(that)) },
"upsert": func(that *Context) { that.Display(0, testUpsert(that)) },
"transaction": func(that *Context) { that.Display(0, testTransaction(that)) },
"rawsql": func(that *Context) { that.Display(0, testRawSQL(that)) },
@@ -650,14 +650,14 @@ func testPagination(that *Context) Map {
}
// ==================== 7. 批量插入测试 ====================
func testBatchInsert(that *Context) Map {
func testInserts(that *Context) Map {
result := Map{"name": "批量插入测试", "tests": Slice{}}
tests := Slice{}
// 7.1 批量插入
test1 := Map{"name": "BatchInsert 批量插入"}
test1 := Map{"name": "Inserts 批量插入"}
timestamp := time.Now().UnixNano()
affected1 := that.Db.BatchInsert("test_batch", []Map{
affected1 := that.Db.Inserts("test_batch", []Map{
{"name": fmt.Sprintf("批量测试1_%d", timestamp), "title": "标题1", "state": 1},
{"name": fmt.Sprintf("批量测试2_%d", timestamp), "title": "标题2", "state": 1},
{"name": fmt.Sprintf("批量测试3_%d", timestamp), "title": "标题3", "state": 1},
@@ -668,9 +668,9 @@ func testBatchInsert(that *Context) Map {
tests = append(tests, test1)
// 7.2 带 [#] 的批量插入
test2 := Map{"name": "BatchInsert 带 [#] 标记"}
test2 := Map{"name": "Inserts 带 [#] 标记"}
timestamp2 := time.Now().UnixNano()
affected2 := that.Db.BatchInsert("test_batch", []Map{
affected2 := that.Db.Inserts("test_batch", []Map{
{"name": fmt.Sprintf("带时间测试1_%d", timestamp2), "title": "标题带时间1", "state": 1, "create_time[#]": "NOW()"},
{"name": fmt.Sprintf("带时间测试2_%d", timestamp2), "title": "标题带时间2", "state": 1, "create_time[#]": "NOW()"},
})