Hood: A transactional, database-agnostic ORM for Go
github.com
github.com
As I note the author is also the submitter, a question: Is it a design goal or possibility to use the ORM but to disable schema generation/migration?
But for legacy databases, for the edge cases where the schema is designed for a very specific purpose that doesn't neatly fit what the ORM would generate, and especially when external applications may also call the database... I like to know that the database is exactly what I expect it to be.
That's where the ORM comes in for legacy stuff. We're moving the schema slowly into the ORM.
hd.Where("name = ?", name).Where("category = ?", category)
So that you can do conditional where easily, for example: hd = hd.Where("name = ?", name)
if category != "" {
hd = hd.Where("category = ?", category)
}
But It doesn't seem to support this? hd.Where("name = ? AND category = ?", name, category)
but it should be quite trivial to add the chaining you pointed out.Follow convention:
type Foo struct {
Thing string `json:"thinger,omitempty" hood:"pk"`
}
Or, even, get bold and claim sql: type Foo struct {
Thing string `json:"thinger,omitempty" sql:"size(128)"`
}
You can then use stuff built in to reflect to get the information for you, rather than parsing yourself:http://golang.org/pkg/reflect/#StructTag
That aside, great work! I've been waiting for something like this.
(Edit: Someone already beat me to it: https://github.com/eaigner/hood/issues/1 -- Hacker Newsers think alike, I guess...)
It's statically typed, so it can check at compile-time that the "messages" being passed are valid, but the dispatch of the messages (ie, methods) is determined by the struct itself, which has the same effect as "extreme late binding" (Kay's words) - the only difference is that Go's type system permits much of this to happen at compile-time anyway.
[1] Which, incidentally, explicitly mentions inheritance as not being a defining point of OO programming.