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

Make beedb map structs to tables/columns by tags instead of putting underlines before capital letters #47

Merged
merged 3 commits into from Feb 9, 2014

Conversation

gabstv
Copy link
Contributor

@gabstv gabstv commented Feb 9, 2014

Since it's not always that you're working with a fresh database to have liberty on using the most comfortable naming convention for tables and columns, I made beedb recognise "sql" tags to map them any way you need (like _mgo_ does with bson tags):

type Car struct {
    Id         int      `beedb:"PK" sql:"ID" tname:"CARS"`
    Name       string   `sql:"car_name"`
    Type       string   `sql:"car_type"`
}

The tag tname is there if you need to specify the table name as well. There could be a better way for this (sadly the struct itself can't have a tag) so I'm open for suggestions.

astaxie added a commit that referenced this pull request Feb 9, 2014
Make beedb map structs to tables/columns by tags instead of putting underlines before capital letters
@astaxie astaxie merged commit 1424055 into astaxie:master Feb 9, 2014
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.

None yet

2 participants