tauri-plugin-mongoose 0.2.3

Tauri plugin for MongoDB/Mongoose-like database operations
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use tauri::command;
use serde_json::Value;
use crate::db::{connect_to_db, create_document, get_document_by_id};

#[command(rename_all = "camelCase")]
pub async fn connect(url: String, db_name: Option<String>) -> Result<(), String> {
    connect_to_db(url, db_name).await
}

#[command]
pub async fn create(collection: String, document: Value) -> Result<Value, String> {
    create_document(collection, document).await
}

#[command]
pub async fn get_by_id(collection: String, id: String) -> Result<Option<Value>, String> {
    get_document_by_id(collection, id).await
}