Skip to content

Commit

Permalink
Merge pull request #3 from cpfiffer/main
Browse files Browse the repository at this point in the history
minor doc corrections
  • Loading branch information
iskyd authored Apr 3, 2024
2 parents e6718a2 + 5f9fee3 commit cb003bd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Wasabi is a simple yet powerful ORM for the Julia Language. It currently support
### Getting Started

```
```julia
using Wasabi
using SQLite

Expand Down
4 changes: 2 additions & 2 deletions docs/src/customtype.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can implement a new custom type just implementing some functions.

Suppose you want to create a JSON type called CustomType that is converted as TEXT on the database.

```
```julia
using SQLite

struct CustomType
Expand All @@ -30,4 +30,4 @@ model = TestModel(1, CustomType(Dict("key" => "value")))
Wasabi.insert!(conn, model)

model = Wasabi.first(conn, TestModel, 1) # model.custom.value["key"] == "value"
```
```
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CurrentModule = Wasabi
Wasabi is a simple ORM for Julia. It currently supports PostgreSQL and SQLite.
Wasabi uses [package extensions](https://github.com/JuliaLang/julia/blob/v1.9.0-beta3/NEWS.md#package-manager) so it requires Julia >= 1.9 to run. Using SQLite or LibPQ automatically includes Wasabi features to support it as backend database.

```
```julia
using Wasabi
using SQLite

Expand Down
6 changes: 3 additions & 3 deletions docs/src/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ Migrations are an easy way to keep track of database schema updates.

This will generate a folder containing the first migration which create the migration table and keep track of the current status of the database.

```
```julia
using Wasbi

path = "migrations/"
Migrations.generate(path)
```

Next you can update (upgrade/downgrade) the database to the required version doing
```
```julia
using Wasbi
using SQLite

version = "xxx" # using Migrations.get_last_version(path) gives you the latest available migration
Migrations.execute(db, path, version)
```
```
10 changes: 5 additions & 5 deletions docs/src/querybuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CurrentModule = Wasabi.QueryBuilder
# QueryBuilder

You can use QueryBuilder to create and execute a query in a simple and fast way.
```
```julia
using Wasabi
using SQLite

Expand All @@ -25,7 +25,7 @@ QueryBuilder supports select, join, where, limit, offset, group by and order by.

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.

```
```julia
QueryBuilder.from(User) |> QueryBuilder.select() # Select all fields from user model
QueryBuilder.from(User) |> QueryBuilder.select([:id, :name]) # SELECT user_alias.id, user_alias.name FROM user user_alias
QueryBuilder.from(User) |> QueryBuilder.select(User, :id, :total, :count) # SELECT COUNT(user_alias.id) AS total FROM user user_alias
Expand All @@ -35,15 +35,15 @@ Join are expressed using source, target, type (inner, outer ...), on, select.
Here's an example to join User with UserProfile using an INNER JOIN and selecting the "bio" column from UserProfile .


```
```julia
query = QueryBuilder.from(User) |> QueryBuilder.select() |> QueryBuilder.join(User, UserProfile, :inner, (:id, :user_id), [:bio])

# SELECT user.id, user.name, user_profile.bio FROM "user" user INNER JOIN "user_profile" user_profile ON user.id = user_profile.user_id
```

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).

```
```julia
query = QueryBuilder.from(User) |> QueryBuilder.select() |> QueryBuilder.where(:(or, (User, name, like, "%mattia%"), (User, id, in, [1, 2, 3]))) |> QueryBuilder.limit(1)
sql, params = QueryBuilder.build(query)

Expand All @@ -57,4 +57,4 @@ Modules = [Wasabi.QueryBuilder]

```@autodocs
Modules = [Wasabi.QueryBuilder]
```
```

0 comments on commit cb003bd

Please sign in to comment.