mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
fmt
This commit is contained in:
@@ -13,6 +13,7 @@ There are three general methods of installation that we can recommend.
|
||||
Install the Core plugin by adding the following to your `Cargo.toml` file:
|
||||
|
||||
`src-tauri/Cargo.toml`
|
||||
|
||||
```toml
|
||||
[dependencies.tauri-plugin-sql]
|
||||
git = "https://github.com/tauri-apps/plugins-workspace"
|
||||
@@ -28,7 +29,7 @@ You can install the JavaScript Guest bindings using your preferred JavaScript pa
|
||||
pnpm add https://github.com/tauri-apps/tauri-plugin-sql
|
||||
# or
|
||||
npm add https://github.com/tauri-apps/tauri-plugin-sql
|
||||
# or
|
||||
# or
|
||||
yarn add https://github.com/tauri-apps/tauri-plugin-sql
|
||||
```
|
||||
|
||||
@@ -37,6 +38,7 @@ yarn add https://github.com/tauri-apps/tauri-plugin-sql
|
||||
First you need to register the core plugin with Tauri:
|
||||
|
||||
`src-tauri/src/main.rs`
|
||||
|
||||
```rust
|
||||
fn main() {
|
||||
tauri::Builder::default()
|
||||
@@ -49,16 +51,16 @@ fn main() {
|
||||
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
|
||||
|
||||
```javascript
|
||||
import Database from 'tauri-plugin-sql-api'
|
||||
import Database from "tauri-plugin-sql-api";
|
||||
|
||||
// sqlite. The path is relative to `tauri::api::path::BaseDirectory::App`.
|
||||
const db = await Database.load('sqlite:test.db')
|
||||
const db = await Database.load("sqlite:test.db");
|
||||
// mysql
|
||||
const db = await Database.load('mysql://user:pass@host/database')
|
||||
const db = await Database.load("mysql://user:pass@host/database");
|
||||
// postgres
|
||||
const db = await Database.load('postgres://postgres:password@localhost/test')
|
||||
const db = await Database.load("postgres://postgres:password@localhost/test");
|
||||
|
||||
await db.execute('INSERT INTO ...')
|
||||
await db.execute("INSERT INTO ...");
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Reference in New Issue
Block a user