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

JOIN support #4

Closed
aperture147 opened this issue Nov 27, 2022 · 6 comments
Closed

JOIN support #4

aperture147 opened this issue Nov 27, 2022 · 6 comments

Comments

@aperture147
Copy link

Is there anyway to perform JOIN query? If there is, how can I do it?

@G4brym
Copy link
Owner

G4brym commented Dec 27, 2022

Hey @aperture147 I will be looking into adding support for this next week
Thanks for suggesting this 😄

@G4brym
Copy link
Owner

G4brym commented Jan 2, 2023

Hey @aperture147
I've just added support for join clauses in the latest v0.1.3 version
You can read the docs here

Let me know if you have any more suggestion

@G4brym G4brym closed this as completed Jan 2, 2023
@subhendukundu
Copy link

fields: ['role', 'department', 'payroll.salary'], returning the data in the same level of the object. Would it possible to have the salary key in the payroll object?

@aperture147
Copy link
Author

Thanks for your support! Is there any way to perform joining on multiple table? We can change

_join(value?: Join): string {
from accepting a single Join object to an array of Join? Eg:

  _join(values?: Array<Join>): string {
    if (!values || !values.length) return ''
    let joinQuery = ''
    values.forEach((item: Join) => {
        const type = value.type ? ` ${value.type}` : ''
        joinQuery += `${type} JOIN ${value.table} ON ${value.on}`
    })

    return joinQuery
  }

This is a rough implementation to show the idea, sorry if it does not work.

@G4brym
Copy link
Owner

G4brym commented Feb 6, 2023

Hey @subhendukundu that kind of result transformation should be handled in your application, workers-qb is only meant to generate sql queries

@G4brym
Copy link
Owner

G4brym commented Feb 6, 2023

Hey @aperture147 I've just added support for multiple joins, checkout the docs here
https://workers-qb.massadas.com/advanced-queries/join/#multiple-joins

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

No branches or pull requests

3 participants