Skip to content

Commit

Permalink
Move platforms into own section
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Sep 17, 2023
1 parent ba20f80 commit ae2b1b4
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 35 deletions.
2 changes: 1 addition & 1 deletion docs/pages/docs/Advanced Features/builder_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ We currently support the following extensions:
Enabling this option is safe when using a `NativeDatabase` with `sqlite3_flutter_libs`,
which compiles sqlite3 with the R*Tree extension enabled.
- `moor_ffi`: Enables support for functions that are only available when using a `NativeDatabase`. This contains `pow`, `sqrt` and a variety
of trigonometric functions. Details on those functions are available [here]({{ "../Other engines/vm.md#moor-only-functions" | pageUrl }}).
of trigonometric functions. Details on those functions are available [here]({{ "../Platforms/vm.md#moor-only-functions" | pageUrl }}).
- `math`: Assumes that sqlite3 was compiled with [math functions](https://www.sqlite.org/lang_mathfunc.html).
This module is largely incompatible with the `moor_ffi` module.
- `spellfix1`: Assumes that the [spellfix1](https://www.sqlite.org/spellfix1.html)
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/docs/Dart API/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ with the `separator` argument on `groupConcat`.

When using a `NativeDatabase`, a basic set of trigonometric functions will be available.
It also defines the `REGEXP` function, which allows you to use `a REGEXP b` in sql queries.
For more information, see the [list of functions]({{ "../Other engines/vm.md#moor-only-functions" | pageUrl }}) here.
For more information, see the [list of functions]({{ "../Platforms/vm.md#moor-only-functions" | pageUrl }}) here.

## Subqueries

Expand Down
11 changes: 0 additions & 11 deletions docs/pages/docs/Getting started/writing_queries.md

This file was deleted.

7 changes: 0 additions & 7 deletions docs/pages/docs/Other engines/index.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ On iOS and macOS, no additional setup is necessary - simply depend on `sqlcipher

On Windows and Linux, you currently have to include a version of SQLCipher manually when you distribute
your app.
For more information on this, you can use the documentation [here]({{ '../platforms.md#bundling-sqlite-with-your-app' | pageUrl }}).
For more information on this, you can use the documentation [here]({{ '../Platforms/index.md#bundling-sqlite-with-your-app' | pageUrl }}).
Instead of including `sqlite3.dll` or `libsqlite3.so`, you'd include the respective versions
of SQLCipher.

Expand Down
23 changes: 12 additions & 11 deletions docs/pages/docs/platforms.md → docs/pages/docs/Platforms/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
data:
title: "Supported platforms"
description: All platforms supported by drift, and how to use them
template: layouts/docs/single
template: layouts/docs/list
---

Being built on top of the sqlite3 database, drift can run on almost every Dart platform.
Expand All @@ -14,7 +14,8 @@ To achieve platform independence, drift separates its core apis from a platform-
database implementation. The core apis are pure-Dart and run on all Dart platforms, even
outside of Flutter. When writing drift apps, prefer to mainly use the apis in
`package:drift/drift.dart` as they are guaranteed to work across all platforms.
Depending on your platform, you can choose a different `QueryExecutor`.
Depending on your platform, you can choose a different `QueryExecutor` - the interface
binding the core drift library with native databases.

## Overview

Expand All @@ -23,8 +24,8 @@ This table list all supported drift implementations and on which platforms they
| Implementation | Supported platforms | Notes |
|----------------|---------------------|-------|
| `SqfliteQueryExecutor` from `package:drift_sqflite` | Android, iOS | Uses platform channels, Flutter only, no isolate support, doesn't support `flutter test`. Formerly known as `moor_flutter` |
| `NativeDatabase` from `package:drift/native.dart` | Android, iOS, Windows, Linux, macOS | No further setup is required for Flutter users. For support outside of Flutter, or in `flutter test`, see the [desktop](#desktop) section below. Usage in a [isolate]({{ 'Advanced Features/isolates.md' | pageUrl }}) is recommended. Formerly known as `package:moor/ffi.dart`. |
| `WasmDatabase` from `package:drift/wasm.dart` | Web | Works with or without Flutter. A bit of [additional setup]({{ 'Other engines/web.md' | pageUrl }}) is required. |
| `NativeDatabase` from `package:drift/native.dart` | Android, iOS, Windows, Linux, macOS | No further setup is required for Flutter users. For support outside of Flutter, or in `flutter test`, see the [desktop](#desktop) section below. Usage in a [isolate]({{ '../Advanced Features/isolates.md' | pageUrl }}) is recommended. Formerly known as `package:moor/ffi.dart`. |
| `WasmDatabase` from `package:drift/wasm.dart` | Web | Works with or without Flutter. A bit of [additional setup]({{ 'web.md' | pageUrl }}) is required. |
| `WebDatabase` from `package:drift/web.dart` | Web | Deprecated in favor of `WasmDatabase`. |

To support all platforms in a shared codebase, you only need to change how you open your database, all other usages can stay the same.
Expand All @@ -47,7 +48,7 @@ is maintaned and supported too.
### using `drift/native`

The new `package:drift/native.dart` implementation uses `dart:ffi` to bind to sqlite3's native C apis.
This is the recommended approach for newer projects as described in the [getting started]({{ "setup.md" | pageUrl }}) guide.
This is the recommended approach for newer projects as described in the [getting started]({{ "../setup.md" | pageUrl }}) guide.

To ensure that your app ships with the latest sqlite3 version, also add a dependency to the `sqlite3_flutter_libs`
package when using `package:drift/native.dart`!
Expand All @@ -73,12 +74,12 @@ However, there are some smaller issues on some devices that you should be aware

## Web

_Main article: [Web]({{ "Other engines/web.md" | pageUrl }})_
_Main article: [Web]({{ "web.md" | pageUrl }})_

For apps that run on the web, you can use drift's experimental web implementation, located
in `package:drift/web.dart`.
As it binds to [sql.js](https:/sql-js/sql.js), special setup is required. Please
read the main article for details.
Drift runs on the web by compiling sqlite3 to a WebAssembly module. This database
can be accessed using a `WasmDatabase` in `package:drift/wasm.dart`.
For optimal support across different browsers, a worker script and some additional
setup is required. The main article explains how to set up drift to work on the web.

## Desktop

Expand Down Expand Up @@ -142,7 +143,7 @@ lives next to your application:
{% include "blocks/snippet" snippets = snippets %}

Be sure to use drift _after_ you set the platform-specific overrides.
When you use drift in [another isolate]({{ 'Advanced Features/isolates.md' | pageUrl }}),
When you use drift in [another isolate]({{ '../Advanced Features/isolates.md' | pageUrl }}),
you'll also need to apply the opening overrides on that background isolate.
You can call them in the isolate's entrypoint before using any drift apis.

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/pages/docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ If you're wondering why so many packages are necessary, here's a quick overview
- `drift`: This is the core package defining the APIs you use to access drift databases.
- `sqlite3_flutter_libs`: Ships the latest `sqlite3` version with your Android or iOS app. This is not required when you're _not_ using Flutter,
but then you need to take care of including `sqlite3` yourself.
For an overview on other platforms, see [platforms]({{ 'platforms.md' | pageUrl }}).
For an overview on other platforms, see [platforms]({{ 'Platforms/index.md' | pageUrl }}).
Note that the `sqlite3_flutter_libs` package will include the native sqlite3 library for the following
architectures: `armv8`, `armv7`, `x86` and `x86_64`.
Most Flutter apps don't run on 32-bit x86 devices without further setup, so you should
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

Other database libraries can easily be integrated into drift as well.

[All platforms]({{ "docs/platforms.md" | pageUrl }})
[All platforms]({{ "docs/Platforms/index.md" | pageUrl }})
{% endblock %}
{% endblock %}

Expand Down
1 change: 0 additions & 1 deletion docs/templates/partials/dependencies.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
- `drift`: This is the core package defining the APIs you use to access drift databases.
- `sqlite3_flutter_libs`: Ships the latest `sqlite3` version with your Android or iOS app. This is not required when you're _not_ using Flutter,
but then you need to take care of including `sqlite3` yourself.
For an overview on other platforms, see [platforms]({{ '../platforms.md' | pageUrl }}).
Note that the `sqlite3_flutter_libs` package will include the native sqlite3 library for the following
architectures: `armv8`, `armv7`, `x86` and `x86_64`.
Most Flutter apps don't run on 32-bit x86 devices without further setup, so you should
Expand Down

0 comments on commit ae2b1b4

Please sign in to comment.