refactor(db): 重命名批量插入方法并更新文档
- 将 BatchInsert 方法重命名为 Inserts,以更好地反映其功能 - 更新示例代码和文档,确保使用新方法名 - 删除过时的文档文件,整合 HoTimeDB 使用说明和 API 参考 - 优化 README.md,增强框架特性和安装说明的清晰度
This commit is contained in:
@@ -766,12 +766,12 @@ correctUsers4 := db.Select("user", "*", common.Map{
|
||||
_ = db
|
||||
}
|
||||
|
||||
// BatchInsertExample 批量插入示例
|
||||
func BatchInsertExample(database *db.HoTimeDB) {
|
||||
// InsertsExample 批量插入示例
|
||||
func InsertsExample(database *db.HoTimeDB) {
|
||||
fmt.Println("\n=== 批量插入示例 ===")
|
||||
|
||||
// 批量插入用户(使用 []Map 格式)
|
||||
affected := database.BatchInsert("user", []common.Map{
|
||||
affected := database.Inserts("user", []common.Map{
|
||||
{"name": "批量用户1", "email": "batch1@example.com", "age": 25, "status": 1},
|
||||
{"name": "批量用户2", "email": "batch2@example.com", "age": 30, "status": 1},
|
||||
{"name": "批量用户3", "email": "batch3@example.com", "age": 28, "status": 1},
|
||||
@@ -779,7 +779,7 @@ func BatchInsertExample(database *db.HoTimeDB) {
|
||||
fmt.Printf("批量插入了 %d 条用户记录\n", affected)
|
||||
|
||||
// 批量插入日志(使用 [#] 标记直接 SQL)
|
||||
logAffected := database.BatchInsert("log", []common.Map{
|
||||
logAffected := database.Inserts("log", []common.Map{
|
||||
{"user_id": 1, "action": "login", "ip": "192.168.1.1", "created_time[#]": "NOW()"},
|
||||
{"user_id": 2, "action": "logout", "ip": "192.168.1.2", "created_time[#]": "NOW()"},
|
||||
{"user_id": 3, "action": "view", "ip": "192.168.1.3", "created_time[#]": "NOW()"},
|
||||
@@ -838,7 +838,7 @@ func RunAllFixedExamples() {
|
||||
fmt.Println("所有示例代码已修正完毕,语法正确!")
|
||||
fmt.Println("")
|
||||
fmt.Println("新增功能示例说明:")
|
||||
fmt.Println(" - BatchInsertExample(db): 批量插入示例,使用 []Map 格式")
|
||||
fmt.Println(" - InsertsExample(db): 批量插入示例,使用 []Map 格式")
|
||||
fmt.Println(" - UpsertExample(db): 插入或更新示例")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user