
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
@tusent.io/json-database
Advanced tools
A super lightweight synchronous database/settings module for local storage of key-value data.
A Node.js module for storing data in files on the local machine. It's basically a settings manager.
This is only meant to be used by a single application since it doesn't automatically reload the file after another application has edited it. When it saves the file, it rewrites the entire file to disk.
json-database is available for installation through npm using the npm install
command.
npm install @tusent.io/json-database --save
const Database = require('json-database');
// Load existing database or create
const db = new Database('./data.json');
// Gets with specified defaults
let dataVersion = db.get('dataVersion', Number.MIN_SAFE_INTEGER);
let userCount = db.get('userCount', 0);
/**
* If performance is not of the essence:
*/
if (dataVersion < 7) {
// Save backup file to './data.json.bak'
db.save(db.path + '.bak');
for (let i = 0; i < userCount; i++) {
let username = db.get(`users.${i}.name`); // (defaults to null)
if (username !== null) {
// Save for each setting
db.set(`users.${i}.name`, null);
db.set(`username${i}`, username);
}
}
db.set('dataVersion', 7);
console.log('Updated database to data version 7.');
}
/**
* Same thing but more performant (fewer writes to disk):
*/
if (dataVersion < 7) {
// Save backup file to './data.json.bak'
db.save(db.path + '.bak');
for (let i = 0; i < userCount; i++) {
let username = db.get(`users.${i}.name`); // (defaults to null)
if (username !== null) {
// Set values without saving
db.set(`users.${i}.name`, null, false);
db.set(`username${i}`, username, false);
}
}
// Save database file
db.save();
// Saves here as well (above save is redundant)
db.set('dataVersion', 7);
console.log('Updated database to data version 7.');
}
Note that I/O errors thrown by the fs-module are not caught and must be caught by the user of this module. The affected methods are Database.save
, Database.set
(unless called with save
parameter set to false
), and Database.constructor
.
FAQs
A super lightweight synchronous database/settings module for local storage of key-value data.
The npm package @tusent.io/json-database receives a total of 3 weekly downloads. As such, @tusent.io/json-database popularity was classified as not popular.
We found that @tusent.io/json-database 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.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.