gorm

Detailed example referenceherearrow-up-right

Configuration

asjard:
  ## Data-related configuration
  stores:
    ## gorm database related configuration
    gorm:
      ## List of databases
      dbs:
        ## default database configuration
        default:
          ## This field is protected by cipherName
          dsn: root:my-secret-pw@tcp(127.0.0.1:3306)/exmple-database?charset=utf8&parseTime=True&loc=Local
          ## Database driver
          ## mysql, postgres, sqlite, sqlserver, clickhouse
          ## ref: https://gorm.io/zh_CN/docs/connecting_to_the_database.html#PostgreSQL
          driver: mysql
          ## Name of the cipher component
          ## If not empty, use the cipher component to decrypt before connecting to the database
          cipherName: ""
          ## Cipher component parameters, map[string]any type
          cipherParams: {}
          ## Driver custom configuration
          options:
            ## Inherit asjard.stores.gorm.options
            ## Custom driver name
            ## ref: https://gorm.io/docs/connecting_to_the_database.html#Customize-Driver
            # driverName: ""
      ## Database connection configuration
      options:
        # maxIdleConns: 10
        # maxOpenConns: 1001
        # connMaxIdleTime: 10
        # connMaxLifeTime: 2h
        # debug: false
        # skipInitializeWithVersion: false
        # skipDefaultTransaction: false
        # traceable: false
        # metricsable: false
        # translateError: false

Use

Last updated