
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
cordova-sqlite-utility
Advanced tools
Utilities to make working with cordova-sqlite-storage easier.
Utilities to make working with cordova-sqlite-storage a little easier. Features include:
npm install --save cordova-sqlite-utility
Open or create a SQLite database file.
Argument | Description | Type |
---|---|---|
config | Database configuration. | SQLiteDatabaseConfig |
When opened, the database is set as the current
database and subsequent calls on that SQLite
instance are executed
against that database automatically.
import { SQLite } from 'cordova-sqlite-utility';
const sqlite = new SQLite();
sqlite
.open({ name: 'Awesome.db' })
.then((db) => console.log('Database opened!'));
Close the current
database.
sqlite.close().then(() => console.log('Database closed!'));
Delete the current
database.
sqlite.remove().then(() => console.log('Database deleted!'));
Execute a SQL statement on the current
database.
Argument | Description | Type |
---|---|---|
statement | Statement to execute. | SQLiteStatement |
INSERT
, UPDATE
, and DELETE
statements return a SQLiteResult
object. SELECT
statements return an array of
objects. Use the generic overload to specify the return object type (T[]
) for SELECT
statements.
sqlite.execute <
IAwesome >
{
sql: 'SELECT * FROM AwesomeTable WHERE id = @id',
params: {
id: 83,
},
}.then((data) => console.log(data));
// => IAwesome[]
sqlite
.execute({
sql: 'INSERT INTO AwesomeTable (name) VALUES (@name)',
params: {
name: 'Yoda',
},
})
.then((result) => console.log(result));
// => { insertId: 1, rowsAffected: 1 }
Since the statement
is prepared with SQLite.prepare
before execution, the sql
property can be either a stored
statement (set via SQLiteStore.set
) or inline SQL.
sqlite.execute <
IAwesome >
{
sql: 'Awesome_ReadById',
params: {
id: 83,
},
}.then((data) => console.log(data));
// => IAwesome[]
Execute a batch of SQL statements on the current
database.
Argument | Description | Type |
---|---|---|
statements | Statements to execute. | SQLiteStatement[] |
sqlite
.batch([
{
sql: 'CREATE TABLE IF NOT EXISTS AwesomeTable (id, name)',
},
{
sql: 'INSERT INTO AwesomeTable VALUES (@name)',
params: { name: 'Luke Skywalker' },
},
{
sql: 'INSERT INTO AwesomeTable VALUES (@name)',
params: { name: 'Darth Vader' },
},
])
.then(() => console.log('Batch complete!'));
Like execute
, the batch
method prepares statements with SQLite.prepare
. So, the sql
property can be either a
stored statement (set via SQLiteStore.set
) or inline SQL.
Store SQL statements for reuse.
Add SQL statements to the store.
import { SQLiteStore } from 'cordova-sqlite-utility';
SQLiteStore.set({
Awesome_Create: 'INSERT INTO AwesomeTable VALUES (@name)',
Awesome_ReadById: 'SELECT * FROM AwesomeTable WHERE id = @id',
});
Storing SQL statements in files is often more manageable. If you'd like to keep your SQL statements in files, like this ...
./sqlite
Awesome_ReadById.sql
Awesome_Create.sql
...
... then sqlite-cordova-devtools can ready all you SQL files for easy addition to the store.
import { SQLiteStore } from 'cordova-sqlite-utility';
SQLiteStore.set(window['_sqlite']);
Get a stored SQL statement by name.
import { SQLiteStore } from 'cordova-sqlite-utility';
const sql = SQLiteStore.get('Awesome_ReadById');
// => 'SELECT * FROM AwesomeTable WHERE id = @id'
Utility methods can be used outside of the API, for direct use with sqlitePlugin
.
Safely transform named parameters and unsupported data types.
Argument | Description | Type |
---|---|---|
statement | Statement to prepare. | SQLiteStatement |
import { SQLiteUtility } from 'cordova-sqlite-utility';
const prepared = SQLiteUtility.prepare({
sql: 'SELECT * FROM AwesomeTable WHERE id = @id and isActive = @isActive',
params: {
id: 83,
isActive: true,
},
});
console.log(prepared);
// => ['SELECT * FROM AwesomeTable WHERE id = ? and isActive = ?', [83, 1]]
db.executeSql(...prepared, (results) => {
console.log(results);
});
The statement's sql
property is used to first check the SQLite
store for a stored statement. If no stored statement
is found the value itself is used.
const prepared = SQLiteUtility.prepare({
sql: 'Awesome_ReadById',
params: {
id: 83,
},
});
console.log(prepared);
// => ['SELECT * FROM AwesomeTable WHERE id = ?', [83]]
FAQs
Utilities to make working with cordova-sqlite-storage easier.
We found that cordova-sqlite-utility demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.