
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
websql-json
Advanced tools
Web SQLite access library. Communicate easily and cleanly using JSON objects.
Web SQLite access library. Communicate easily and cleanly using JSON objects.
var local = require('websql-json');
Connect:
If you call the connect
method at the start, you do not need to include the name
field on subsequent transactions.
local.connect(data, callback);
var data = {
name: 'database_name',
version: '1.0',
descr: 'database_description',
size: 500000,
};
// or
var data = {
name: 'database_name',
};
name
field is mandatory and must be defined.version
, descr
and size
are all optional fields.
version
is 1.0
. It can only be 1.0
or 2.0
.descr
will be the same as the name of the database.size
is 500000
. Its maximum value is 52428000
.Create:
local.transaction('create', data, callback);
// The `columns` field must be an array of strings
var data = {
name: 'database_name',
data: [
{
table: 'table_a',
columns: ['col1', 'col2'],
},
{
table: 'table_b',
columns: ['col3', 'col4'],
},
],
inserts: [
name: 'database_name',
data: [
{
table: 'table_a',
data: {
col1: 'val1',
col2: 'val2',
},
},
{
table: 'table_b',
data: {
col3: 'val3',
col4: 'val4',
},
},
],
],
};
Drop:
local.transaction('drop', data, callback);
var data = {
name: 'database_name',
data: [
{
table: 'table_a',
},
{
table: 'table_b',
},
],
};
Insert:
local.transaction('insert', data, callback);
var data = {
name: 'database_name',
data: [
{
table: 'table_a',
data: {
col1: 'val1',
col2: 'val2',
},
},
{
table: 'table_b',
data: {
col3: 'val3',
col4: 'val4',
},
},
],
};
// `data` must be an array of JSON objects. e.g.
var data = {
name: 'database_name',
data: [
{
table: 'devices',
name: 'device 1',
type: 'ctrl',
},
{
table: 'devices',
name: 'device 2',
type: 'ctrl',
},
],
};
Delete:
local.transaction('delete', data, callback);
// Delete data where `col1` has a value of `val1`
var data = {
name: 'database_name',
table: 'table_name',
data: {
col1: 'val1',
},
};
// Or delete all data from the table
var data = {
name: 'database_name',
table: 'table_name',
data: {},
};
Update:
local.transaction('update', data, callback);
var data = {
name: 'database_name',
table: 'table_name',
data: {
set: {
col1: 'val1',
col2: 'val2',
},
where: {
col3: 'val3',
col4: 'val4',
},
},
};
// `set` and `where` must be JSON objects with one or many key value pairs. e.g.
var data = {
name: 'database_name',
table: 'devices',
data: {
set: {
name: 'new_device',
},
where: {
type: 'ctrl',
mac: 'ff',
},
},
};
UPDATE devices SET name='new_device' WHERE type='ctrl' AND mac='ff';
set
condition is applied to all rows of the table.set
cannot be emptywhere
can be emptyFind:
local.transaction('find', data, callback);
// Find data where `col1` has a value of `val1` or `val2` or `val3` and `col2` has a value of `val4`
// Additionally join on `table_b` and select all columns from `table_b`
var data = {
name: 'database_name',
table: 'table_a',
data: {
col1: ['val1', 'val2', 'val3'],
col2: 'val4',
},
join: {
query: 'JOIN table_b on table_a.join_id = table_b.id',
},
selects: 'table_b.*',
groupBy: 'join_id',
orderBy: [
'join_id',
'another_column',
],
};
// Or find and return all data from `table_a`
var data = {
name: 'database_name',
table: 'table_a',
data: {},
};
var callbackData = {
// Returned from a CREATE transaction when additional INSERT data is provided
// This allows an INSERT transaction to proceed directly after a CREATE
callbackData: { data: [], name: 'database_name' },
done: flag,
message: message,
queryType: queryType,
// Returned from a FIND transaction as an `SQLResultSetRowList`
rows: [],
};
done
returns true
if the database call is successful, or false
if it is notqueryType
returns the type of query that was executed (e.g. "create", "insert", etc.)message
returns a success or failure string (e.g. "Table created successfully")rows
object keyFAQs
Web SQLite access library. Communicate easily and cleanly using JSON objects.
We found that websql-json demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.