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

Provide more examples in docs #68

Open
bastaware opened this issue Feb 12, 2020 · 1 comment
Open

Provide more examples in docs #68

bastaware opened this issue Feb 12, 2020 · 1 comment

Comments

@bastaware
Copy link

Going through the different db abstractions for Scala I came across Relate. Looks good, but is there a reason the examples are so simple? Please show how to handle joins.

@SrodriguezO
Copy link

Queries with joins should work the same as queries without them. For example,

sql"SELECT users.name, emails.email FROM users INNER JOIN emails ON users.id == emails.user_id".asMap { row =>
  row.long("name") -> row.string("email")
}

should give you a Map of user names to emails.

The query itself can be any valid SQL query. From the docs:

Relate is a lightweight database access layer for Scala that simplifies database interaction while leaving complete control over the actual SQL query.

There's more documentation on the docs page on how to write queries with parameters, query composition, and data retrieval. For general documentation on writing queries with joins, please refer to SQL documentation.

Please let us know if you run into any issues using any valid queries :)

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

2 participants