diff --git a/README.md b/README.md index a3bed7e..ad91687 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/src/customtype.md b/docs/src/customtype.md index e330f60..d837ce9 100644 --- a/docs/src/customtype.md +++ b/docs/src/customtype.md @@ -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 @@ -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" -``` \ No newline at end of file +``` diff --git a/docs/src/index.md b/docs/src/index.md index 225de71..088efc4 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -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 diff --git a/docs/src/migrations.md b/docs/src/migrations.md index 1aa1d87..1e407f0 100644 --- a/docs/src/migrations.md +++ b/docs/src/migrations.md @@ -4,7 +4,7 @@ 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/" @@ -12,10 +12,10 @@ 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) -``` \ No newline at end of file +``` diff --git a/docs/src/querybuilder.md b/docs/src/querybuilder.md index 0b0c237..7513717 100644 --- a/docs/src/querybuilder.md +++ b/docs/src/querybuilder.md @@ -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 @@ -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 @@ -35,7 +35,7 @@ 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 @@ -43,7 +43,7 @@ query = QueryBuilder.from(User) |> QueryBuilder.select() |> QueryBuilder.join(Us 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) @@ -57,4 +57,4 @@ Modules = [Wasabi.QueryBuilder] ```@autodocs Modules = [Wasabi.QueryBuilder] -``` \ No newline at end of file +```