New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@tauri-apps/plugin-sql

Package Overview
Dependencies
Maintainers
5
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tauri-apps/plugin-sql - npm Package Compare versions

Comparing version
2.0.0-beta.2
to
2.0.0-beta.3
+2
-2
package.json
{
"name": "@tauri-apps/plugin-sql",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.3",
"description": "Interface with SQL databases",

@@ -24,3 +24,3 @@ "license": "MIT or APACHE-2.0",

"dependencies": {
"@tauri-apps/api": "2.0.0-beta.4"
"@tauri-apps/api": "2.0.0-beta.11"
},

@@ -27,0 +27,0 @@ "scripts": {

@@ -92,3 +92,3 @@ ![plugin-sql](https://github.com/tauri-apps/plugins-workspace/raw/v2/plugins/sql/banner.png)

const result = await db.execute(
"UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
"UPDATE todos SET title = $1, status = $2 WHERE id = $3",
[todos.title, todos.status, todos.id],

@@ -104,3 +104,3 @@ );

const result = await db.execute(
"UPDATE todos SET title = ?, completed = ? WHERE id = ?",
"UPDATE todos SET title = ?, status = ? WHERE id = ?",
[todos.title, todos.status, todos.id],

@@ -107,0 +107,0 @@ );

'use strict';
var core = require('@tauri-apps/api/core');
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
/**
* **Database**
*
* The `Database` class serves as the primary interface for
* communicating with the rust side of the sql plugin.
*/
class Database {
constructor(path) {
this.path = path;
}
/**
* **load**
*
* A static initializer which connects to the underlying database and
* returns a `Database` instance once a connection to the database is established.
*
* # Sqlite
*
* The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
*
* @example
* ```ts
* const db = await Database.load("sqlite:test.db");
* ```
*/
static async load(path) {
const _path = await core.invoke("plugin:sql|load", {
db: path,
});
return new Database(_path);
}
/**
* **get**
*
* A static initializer which synchronously returns an instance of
* the Database class while deferring the actual database connection
* until the first invocation or selection on the database.
*
* # Sqlite
*
* The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
*
* @example
* ```ts
* const db = Database.get("sqlite:test.db");
* ```
*/
static get(path) {
return new Database(path);
}
/**
* **execute**
*
* Passes a SQL expression to the database for execution.
*
* @example
* ```ts
* // for sqlite & postgres
* // INSERT example
* const result = await db.execute(
* "INSERT into todos (id, title, status) VALUES ($1, $2, $3)",
* [ todos.id, todos.title, todos.status ]
* );
* // UPDATE example
* const result = await db.execute(
* "UPDATE todos SET title = $1, completed = $2 WHERE id = $3",
* [ todos.title, todos.status, todos.id ]
* );
*
* // for mysql
* // INSERT example
* const result = await db.execute(
* "INSERT into todos (id, title, status) VALUES (?, ?, ?)",
* [ todos.id, todos.title, todos.status ]
* );
* // UPDATE example
* const result = await db.execute(
* "UPDATE todos SET title = ?, completed = ? WHERE id = ?",
* [ todos.title, todos.status, todos.id ]
* );
* ```
*/
async execute(query, bindValues) {
const [rowsAffected, lastInsertId] = await core.invoke("plugin:sql|execute", {
db: this.path,
query,
values: bindValues ?? [],
});
return {
lastInsertId,
rowsAffected,
};
}
/**
* **select**
*
* Passes in a SELECT query to the database for execution.
*
* @example
* ```ts
* // for sqlite & postgres
* const result = await db.select(
* "SELECT * from todos WHERE id = $1", id
* );
*
* // for mysql
* const result = await db.select(
* "SELECT * from todos WHERE id = ?", id
* );
* ```
*/
async select(query, bindValues) {
const result = await core.invoke("plugin:sql|select", {
db: this.path,
query,
values: bindValues ?? [],
});
return result;
}
/**
* **close**
*
* Closes the database connection pool.
*
* @example
* ```ts
* const success = await db.close()
* ```
* @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
*/
async close(db) {
const success = await core.invoke("plugin:sql|close", {
db,
});
return success;
}
}
module.exports = Database;