tauri-plugin-polodb

Crates.iotauri-plugin-polodb
lib.rstauri-plugin-polodb
version0.1.0
sourcesrc
created_at2024-09-05 20:17:09.880176
updated_at2024-09-05 20:17:09.880176
descriptionA Tauri plugin to expose the PoloDB embedded database to applications
homepagehttps://github.com/dax-dot-gay/tauri-plugin-polodb
repositoryhttps://github.com/dax-dot-gay/tauri-plugin-polodb
max_upload_size
id1365123
size98,516
Dax Harris (dax-dot-gay)

documentation

README

tauri-plugin-polodb

A Tauri plugin to expose the PoloDB embedded database to applications

Installation

To install the Rust plugin, run:

cargo add tauri-plugin-polodb

Then, load the plugin in your Tauri app as follows:

pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_polodb::init()) // THIS LINE
        // More builder methods
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Finally, install the JS client bindings:

yarn add tauri-plugin-polodb-api

Usage

In the Rust backend, all the PoloDB APIs can be accessed through the AppHandle as follows:

...
app.polodb().<methods>
...

On the client:

import {Database} from "tauri-plugin-polodb-api";

const db = await Database.open("example", "./data"); // Open a database
const collection = db.collection<{[key: string]: any}>("example_collection"); // Get a reference to a collection
console.log(await collection.find_all()); // Returns all records in the collection

For query syntax, reference the PoloDB documentation.

Commit count: 0

cargo fmt