You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can use QueryBuilder to create and execute a query in a simple and fast way.
8
-
```
8
+
```julia
9
9
using Wasabi
10
10
using SQLite
11
11
@@ -25,7 +25,7 @@ QueryBuilder supports select, join, where, limit, offset, group by and order by.
25
25
26
26
Select can be expressed as vector of symbols or using SelectExpr object. If no arguments are passed to select then all fields of the model are selected. You can also use alias and select function like count, sum, avg and so on.
27
27
28
-
```
28
+
```julia
29
29
QueryBuilder.from(User) |> QueryBuilder.select() # Select all fields from user model
30
30
QueryBuilder.from(User) |> QueryBuilder.select([:id, :name]) # SELECT user_alias.id, user_alias.name FROM user user_alias
31
31
QueryBuilder.from(User) |> QueryBuilder.select(User, :id, :total, :count) # SELECT COUNT(user_alias.id) AS total FROM user user_alias
@@ -35,15 +35,15 @@ Join are expressed using source, target, type (inner, outer ...), on, select.
35
35
Here's an example to join User with UserProfile using an INNER JOIN and selecting the "bio" column from UserProfile .
# SELECT user.id, user.name, user_profile.bio FROM "user" user INNER JOIN "user_profile" user_profile ON user.id = user_profile.user_id
42
42
```
43
43
44
44
Where conditions are expressed as Julia Expr object where you can nest and/or conditions. The condition needs to be expressed as (Model, fieldname, function, params).
0 commit comments