
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
A lightweight Node.js module for managing JSON-based databases.
gyo.db is a simple and efficient module that provides easy-to-use functions for managing JSON-based databases. It allows you to store, retrieve, update, and delete data using a JSON file as the storage mechanism.
npm install gyo.db
For detailed usage instructions and API documentation, please refer to the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for more information.
For bug reports, feature requests, or any other questions related to gyo.db, please use the issue tracker on GitHub.
Here is an example of how to use GyoDB in your Node.js application:
const GyoDB = require('gyodb');
// Create an instance of GyoDB with the path to your JSON database file
const db = new GyoDB('data.json');
// Set a value
db.set('name', 'Özcan Kasapoğlu');
// Get a value
const name = db.get('name');
console.log(name); // Output: Özcan Kasapoğlu
// Check if a key exists
const exists = db.has('name');
console.log(exists); // Output: true
// Remove a key-value pair
db.remove('name');
// Clear the entire database
db.clear();
// Get the size of the database
const size = db.size();
console.log(size); // Output: 0
// Search for values that include a specific query
const results = db.search('apple');
console.log(results); // Output: { fruit: 'apple', color: 'red' }
// Update a value using a custom update function
db.update('count', value => value + 1);
// Get the key(s) associated with a specific value
const key = db.getKeyByValue('Özcan Kasapoğlu');
console.log(key); // Output: name
const keys = db.getKeysByValue('apple');
console.log(keys); // Output: [ 'fruit' ]
// Merge an object into the database
db.merge({ city: 'New York', country: 'USA' });
// Validate a value using a custom validation function
const isValid = db.validate('age', value => value >= 18);
console.log(isValid); // Output: true
// Export the database to a JSON file
db.exportDatabase('backup.json');
// Start a web API server to expose the database data
db.startWebAPI(3000);
new GyoDB(dbFilePath)
Creates a new instance of GyoDB with the specified JSON database file path.
loadDatabase()
Loads the JSON database file and returns its contents as an object. If the file does not exist or is empty, an empty object {} is returned.
saveDatabase()
Saves the current state of the database to the JSON file.
get(key)
Retrieves the value associated with the specified key.
set(key, value)
Sets the value of the specified key.
has(key)
Checks if the specified key exists in the database.
remove(key)
Removes the key-value pair associated with the specified key.
clear()
Clears the entire database.
getAll()
Returns the entire database as an object.
size()
Returns the number of key-value pairs in the database.
search(query)
Searches for values that include the specified query and returns an object with matching key-value pairs.
update(key, updateFn)
Updates the value associated with the specified key using a custom update function. The update function receives the current value as a parameter and should return the updated value.
getKeyByValue(value)
Returns the key associated with the specified value. If multiple keys have the same value, only the first occurrence is returned.
getKeysByValue(value)
Returns an array of keys associated with the specified value.
merge(dataObject)
Merges the specified object into the database.
validate(key, validationFn)
Validates the value associated with the specified key using a custom validation function. The validation function receives the value as a parameter and should return a boolean value indicating whether the value is valid or not.
exportDatabase(exportFilePath)
Exports the current state of the database to a JSON file at the specified path.
startWebAPI(port)
Starts a web API server to expose the database data. The server listens on the specified port and provides a JSON API endpoint at /api/data to retrieve the database contents.
FAQs
Lightweight Node.js module for managing JSON-based databases
The npm package gyo.db receives a total of 2 weekly downloads. As such, gyo.db popularity was classified as not popular.
We found that gyo.db 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
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.