Closed DomThePorcupine closed 2 years ago
As you observed, if you have columns of the same name, querying the rows as objects will only give you back one of them 😅
The proper solution in this case is to either rename the rows, or to use one of the query methods that return an array, which doesn’t suffer from the problem:
for (const [businessId, businessName, ownerId, ownerName] of query.iter()) {
// …
}
Hi all,
I have a dumb question here - let's say I've got 2 tables with a 1-1 relationship & overlapping column names (in this case the name and id field):
The tables are populated with some minimal information:
If I want to issue a query to join a business and an owner I could:
As you can see we get the name and id from the
owners
table, but none of the info from thebusinesses
table - so they aren't quite being mapped correctly. It would be possible to issue this query specifying the table in the select statement - but that might lead to cumbersome queries if there are a lot of columns... so my question is:Is that the proper way to approach this problem:
which returns the expected:
or is there some middleground where
makeRowObject
looks like:which would return:
Anyway thanks for your time and the lib :) Dom