Skip to content
This repository was archived by the owner on Jun 19, 2019. It is now read-only.
This repository was archived by the owner on Jun 19, 2019. It is now read-only.

Add db.InsertStruct(Table, *interface{}) support #22

Open
@steelbrain

Description

@steelbrain

This package is extremely helpful when you want to simplify sql usage in your app without requiring the fullness of xorm so thank you for writing it.

One thing that would make this library a lot more useful is a new func on core.DB, It should allow users to specify the table and provide the struct and automatically generate the required sql for it.

For example

user = User{
    Name:"lunny",
    Title:"test",
    Age: 18,
}
result, err = db.ExecStruct("insert into user (`name`, title, age, alias, nick_name,created) values (?Name,?Title,?Age,?Alias,?NickName,?Created)",
            &user)

would become

user = User{
    Name:"lunny",
    Title:"test",
    Age: 18,
}
result, err = db.InsertStruct("user", &user)

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions