Giter Club home page Giter Club logo

gorm-shentong's Introduction

gorm-shentong

使用方式

	db, err := gorm.Open(shentong.New(shentong.Config{
        DSNConfig: &oscar.Config{
            User:   "test",
            Passwd: "testPasswd",
            Host:   "127.0.0.1",
            Port:   2003,
            DBName: "OSRDB",
        },
    }))

可以通过DSNConfig进行组装DSN,也可以直接通过DSN进行配置

    db, err := gorm.Open(shentong.New(shentong.Config{
        DSN: "user/password@host:port/dbname",
    }))

在某些时候需要适配多种数据库,那么我们会编写统一的model结构体,但是在对应到部分数据库时需要对字段名称进行统一的处理,例如转为大写,那么可以通过 FieldConvertType 来进行统一处理

    db, err := gorm.Open(shentong.New(shentong.Config{
        DSN: "user/password@host:port/dbname",
        FieldConvertType: shentong.Upper,
    }))

也可以通过 FieldConvertFunc 来进行自定义的处理

    db, err := gorm.Open(shentong.New(shentong.Config{
        DSN: "user/password@host:port/dbname",
        FieldConvertFunc: func(field string) string {
            return strings.ToUpper(field)
        },
    }))

编译说明

TODO

gorm-shentong's People

Contributors

mystery00 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.