Hacker News new | ask | show | jobs
by mdasen 3480 days ago
One of the features listed is "Mapping with nested structs", but there's no example of this. Given that this would be a feature setting your project apart from many of the Go "ORMs" out there, it would be nice to have an example.

Maybe something with two tables: an "authors" table and a "books" table. Then an example of getting authors each struct of which has a `[]Book` of books.

1 comments

Nested structs are shown in the documentation : https://godoc.org/github.com/samonzeweb/godb#hdr-Structs_map...

It's composition tool, not a relational one. Sorry.

> It's composition tool, not a relational one. Sorry.

Isn't the R in ORM for relational?

> > It's composition tool, not a relational one. Sorry.

> Isn't the R in ORM for relational?

I spoke about the nested structs. You can have nested structs for something else than relational mapping.

As I replied to masklinn , I was not sure how to qualify godb, and I admit that ORM is not a perfect qualifier.

Your library is a query builder, not an ORM.
ORM is a tool to map an object model (with which the developer interacts) onto a relational one, the R part is the one which ORMs try to hide, not the one they're trying to surface.
> ORM is a tool to map an object model

No, ORM means Object Relational Mapper. if your ORM doesn't support relations between tables, then it is not a ORM.

Given a relationship between 2 tables, an ORM will at the very least fetch related records when rows from a table are loaded.

> godb does not manage relationships like Active Record or Entity Framework,

Godb is therefore NOT an ORM. The title is misleading. People can't just make up definitions like that. It's either an ORM or it is not.

Godb looks like a simple query builder.

Relational comes from Relation which means "table", not relationship.

There's no relationship between 2 tables. You're probably referring to foreign keys, but these are just constraints, not relationships in the sense you're alluding in your comment.

While that may be true in the definition of a relational database, that is not generally what is meant by an ORM. The relationships between objects are a key part of what an ORM would provide.
Relation DOES NOT mean table. Relation does mean relations in the context of the Entity/Relationship model. It has nothing to do with tables, at all. So you are partially right technically I should have used the word entity, not table. But relation does not mean table again.
> Godb is therefore NOT an ORM. […] Godb looks like a simple query builder.

Yeah I already said that: https://news.ycombinator.com/item?id=13184341