Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Association query #14

Open
Brooooooklyn opened this issue Aug 1, 2017 · 5 comments
Open

Association query #14

Brooooooklyn opened this issue Aug 1, 2017 · 5 comments

Comments

@Brooooooklyn
Copy link
Contributor

Brooooooklyn commented Aug 1, 2017

Transform

{
  _id: 'pseudo_xxxx',
  creatorId: '123456'
  creator: {
    id: '123456'
    name: 'xxx',
    gender: 'male'
  }
}

to

SELECT 
  _id,
  Member.id,
  Member.name,
  Member.gender
FROM Message 
JOIN Member ON Message.creatorId = Member.id
WHERE Member.gender = 'male'
@Saviio
Copy link
Contributor

Saviio commented Aug 8, 2017

我发现这里可能会牵涉到一个self-join的二义性 - -

SELECT 
  _ID,
  Member.id,
  Member.name
FROM Member
JOIN Member AS M2 ON Member.manager = M2.name
WHERE M2.name = 'hahaha' 

由于reactivedb里 AS 这个步骤是我们自己指定的,外部无法直接具名,所以 association query 可能需要添加在这里

  fields: ['_id', 'name', 'content', {
    project: ['_id', 'name'],
    executor: ['_id', 'name', 'avatarUrl']
  }]

from https://github.com/ReactiveDB/core/blob/master/docs/API-description/QueryDescription.md

或者为QueryDescription新加一个字段叫associationClause (随便起的) ?

@Saviio
Copy link
Contributor

Saviio commented Aug 8, 2017

讲道理,那个子句约束,应该算在 joinInfo的一部分

@Brooooooklyn
Copy link
Contributor Author

Brooooooklyn commented Aug 8, 2017

约束放在 joinInfo 里面实现起来是最方便的,但是接口可能就没法很好看了。
我想实现成 Nested Key 这样:

{
  'member.age': {
    $gt: 10
  }
}

@Saviio
Copy link
Contributor

Saviio commented Aug 8, 2017

容我想想看看这样能不能自动 match 上 alias 过的 join table吗

@Saviio
Copy link
Contributor

Saviio commented Aug 9, 2017

好像是可以的,match 对象 virtual referrence 的 key 就好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants