Shawn Long
Explore posts from serversSelectAll Overwrites column with same field name in a join
Hello, very odd issue here. I have a table Course with field 'id' and User with field 'id'. When I join these two tables and SelectAll(['Course', 'User']), there's only a single id field, with the value from User. Is this a bug, or am I doing something wrong? (Detailed snippets below).
result:
{
id: 'a0no2ltsuo8chdfaws5l2arqyzhcjp', // <-- this is the actual course ID
instructorId: 'dabkdqgh29j4cfkef3u1b8p63zcjhj',
title: 'Rustic Wooden Ball'
}
result:
{
id: 'dabkdqgh29j4cfkef3u1b8p63zcjhj', // <-- this is now the user id
instructorId: 'dabkdqgh29j4cfkef3u1b8p63zcjhj',
title: 'Rustic Wooden Ball',
name: 'Penny Stroman',
}
8 replies
Separating results of join into objects of each type
Hey guys, I'm curious if anyone knows a way to unmerge the results of a join into objects of both types. For example, if you have a table User and table Bio, and query a single row which joins those two, the result is an a flat object with keys from both tables. What I'd like to do is separate the result into a User object and Bio object.
Solutions that work but I don't love:
1. manually extracting values from the object based on the current schema. (future changes to schema will break this, so I'd like to avoid that)
2. Multiple database queries for each object (this lengthens load times, which isn't a great solution for me either).
Let me know what you guys think and if you were able to find a good solution for this, or if I should just bite the bullet and go with solution 1.
5 replies