C
C
Chronic 862018-11-06 20:22:55
go
Chronic 86, 2018-11-06 20:22:55

Organization of requests in go?

DB with three tables.
Peoples( Id, Name, PlaceId)
Places( Id, Place )
How to get a table of people with their places of work?
Go provides an API.
What is the best way to organize models?
Should there be two models for each table, or is one model enough to contain the structure I need?
If there are two models, how should they communicate with each other?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Petro Kvartsianyi, 2019-01-23
@Patrick12

Each model needs its own structure. In the worker model, store the key of the place of work (go for another model).
And make the request "take a place of work where id == worker.id".
But if your "model" of the place of work contains only one field (a string, for example), you can simply keep this field in the worker model and not create a separate table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question