Skip to content

Commit 19a5f68

Browse files
committed
feat(docs): update model
1 parent 653abcb commit 19a5f68

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

docs/src/guide/develop/model.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -344,38 +344,39 @@ rest:
344344
port: 8001
345345
timeout: 20000
346346
347-
databaseType: "mysql"
348-
databaseUrl: "root:123456@tcp(127.0.0.1:3306)/jzeroadmin?charset=utf8mb4&parseTime=True&loc=Local"
347+
sqlx:
348+
driverName: "mysql"
349+
dataSource: "root:123456@tcp(127.0.0.1:3306)/jzeroadmin?charset=utf8mb4&parseTime=True&loc=Local"
349350
350351
redis:
351352
host: "127.0.0.1:6379"
352353
type: "node"
353354
354-
cache:
355-
type: "redis"
355+
cacheType: "redis"
356356
```
357357

358358
@tab internal/config/config.go
359+
359360
```go {4,5,13-19}
360361
package config
361362
362363
import (
363-
"github.com/jzero-io/jzero/core/stores/modelx"
364364
"github.com/zeromicro/go-zero/core/stores/redis"
365+
"github.com/zeromicro/go-zero/core/stores/sqlx"
365366
"github.com/zeromicro/go-zero/rest"
366367
)
367368
368369
type Config struct {
369370
// rest 服务配置
370-
Rest RestConf
371+
Rest RestConf
371372
372373
// 数据库配置
373-
modelx.ModelConf
374+
Sqlx sqlx.SqlConf
374375
// 缓存配置
375376
// 缓存类型
376-
CacheType string `json:",default=local"`
377+
CacheType string `json:",default=local"`
377378
// redis 配置
378-
Redis redis.RedisConf `json:",optional"`
379+
Redis redis.RedisConf `json:",optional"`
379380
}
380381

381382
type RestConf struct {
@@ -416,7 +417,7 @@ func NewServiceContext(cc configurator.Configurator[config.Config], route2Code f
416417
Config: cc,
417418
}
418419
svcCtx.SetConfigListener()
419-
svcCtx.SqlxConn = modelx.MustSqlConn(svcCtx.MustGetConfig().ModelConf)
420+
svcCtx.SqlxConn = sqlx.MustNewConn(svcCtx.MustGetConfig().Sqlx)
420421
if svcCtx.MustGetConfig().CacheType == "local" {
421422
svcCtx.Cache = cache.NewSyncMap(errors.New("cache not found"))
422423
} else {

0 commit comments

Comments
 (0)