agiletiger / ojotas

The database-first ORM
MIT License
7 stars 4 forks source link

investigate: auto querying primary key to simplify assemble #1

Open nicoabie opened 10 months ago

nicoabie commented 10 months ago

In V1 of ojotas it is needed that the user specifies for each query where relations are being included which key is going to serve as the unique identifier of each object. This is important for deduping purposes

ie:

select j.jobNumber, jl.locationId, jl.dispatcherNotes from job j inner join job_location jl on j.jobId = jl.jobId;

We need to tell ojotas (manually) that jobNumber and locationId are the unique identifiers of those entities.

Another possibility would be that ojotas always include in the sql query the primary key of each object. Use that to do the assemble and then discard it so the user only gets what they asked for. Sequelize does this behind the scenes too to have better DX when manually specifying attributes.