4 ms·
Author here. One question I often get about Martini is how to hook it up to a database. I hope this post helps explain the Martini workflow a bit more!
by codegangsta 13y ago
Author here. One question I often get about Martini is how to hook it up to a database. I hope this post helps explain the Martini workflow a bit more!
- toni 13y agoIn the event you feel like answering, most martini examples I have seen instruct us to execute `go run main.go`. Is that the "right" way to run martini? Shouldn't I compile my martini app first?
- BarkMore 13y agoThis is not the recommended way to run Go applications, including those using Martini. Use "go build" or "go install" to build a binary and then execute the binary.
- codegangsta 13y ago`go run` compiles your app already. In the case that you have multiple files in your package you will need to run `go build`
- pjschlic 13y agoI'm not familiar with Martini, but it looks like DB() is mapping a connection to the "advent" db based on the idea I'm asking for a mgo.Database. It makes me wonder how I might have multiple databases used by my server - maybe if advent lists and user logins were in different databases or something?