blue-jay / blueprint

Blueprint for your next web application in Go.
https://blue-jay.github.io/
MIT License
481 stars 77 forks source link

Gorm Documenation #79

Open Light-Wizzard opened 6 years ago

Light-Wizzard commented 6 years ago

Referring to these docs https://github.com/blue-jay/blueprint/wiki/Use-Gorm-with-Blueprint Under Example Model you have: database "github.com/blue-jay/blueprint/lib/gorm" I assume you downloaded the gorm project and its pointing to it In the example code for gorm and mysql they point to a more specific point "github.com/jinzhu/gorm/dialects/mysql" the mysql.go only has one import github.com/go-sql-driver/mysql Now my understanding of an import alias is that some function has the name your looking for, in this case its database.SQL. so its looking for SQL and cannot find it, I did find it in the driver file, but it states its undefined. It would be nice to get this working, not sure what I am doing wrong, new to go and could not find an example that helped.

Update:

Adding this: var (
// SQL wrapper SQL *database.DB )

I fixed the calls by adding db database.DB, to both ByEmail and Create and faked the returns, but you use flight and that is where I am stuck is how to make sqlx and gorm work together so I change them out type sqlx.DB as type *gorm.DB

Notes and Registry needs updating:

I want to convert the whole project so I can use what ever database I want, SQLite for now, most people want a choice, if your going to document something it should work, if you want your project to use gorm is your decision, but the options for others to use it will increase your ranking and make this project more popular because it will be more flexible, you can add what type of database to use in the config file, then this app would really rock.

Making progress: do you have a working example of this?

Thanks

josephspurrier commented 6 years ago

Thank you for the feedback. I have to admit I didn't follow great practices when I wrote Blue Jay - if you want great practices, please look at my API that I'm extremely happy with. https://github.com/josephspurrier/gowebapi. It's testable, pluggable, and has Swagger to go along with it.

I don't have a working example of Gorm, I'm sorry.