agiletiger / agiletiger/ojotas

investigate: using sql aliases to give hints to ojotas on how do the assemble

未关闭
#3 2 条评论 0 个 reaction 已指派 1 人 已被 @ivanlolivier 认领 在 GitHub 查看
主要语言
TypeScript
星标
9
派生
4
PR 合并指标
30 天内没有已合并 PR

描述

today ojotas needs a list of identifiers to know how to do the assemble when querying an entity with its relations
it also needs a config file, the ojotasrc.json with aliases and relations

another way would be to have sql queries like this one

```sql
select
u.name as 'name',
p.title as 'posts[].title',
p.content as 'posts[].content'
from
users u left join
posts p on u.id = p.user_id
;
```

with this we would not need the configuaration file and it will be more flexible like if we want to return a single post we could do

```sql
select
u.name as 'name',
p.title as 'lastPost.title',
p.content as 'lastPost.content'
from
users u left join
posts p on u.id = p.user_id
where
u.id = 1
order by p.createdAt desc
limit 1
;
```

instrad of having an array with just one post we could directy have an object lastPost.

I believe both ways could co exist depending on user preference on how to work

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。