Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add not_ai tag #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add not_ai tag #13

wants to merge 1 commit into from

Conversation

nobokoba
Copy link

@nobokoba nobokoba commented Mar 4, 2016

If primarykey is an integer , will be removed also have been included in the structure , I want to directly INSERT an integer value . Use for example, INSERT to a dependent table .

usage:

CREATE TABLE `user` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(64) NOT NULL,
)
CREATE TABLE `user_setting` (
  `user_id` int(11) NOT NULL,
  `some_setting_value` int(11) NOT NULL,
)
type User struct {
    Id         int    `db:"pk" column:"user_id"`
    Username string
}
type UserSetting struct {
    UserId int `db:"pk,not_ai"`
    SomeSettingValue int `db:"pk"`
}

user := &User {
    Username : "USER_NAME",
}
db.Insert(user)
setting := &UserSetting {
    UserId : user.Id,
    SomeSettingValue: 1
}
db.Insert(setting)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants