my-pocket.db
v1.1.0
Published
Cool database package
Downloads
8
Readme
Pocket is a simple database implementation in JavaScript/TypeScript that allows you to store data using either JSON or SQLite.
Installation
You can install the package via npm:
npm install my-pocket.dbUsage
const { Pocket } = require('my-pocket.db');
// Create a new Pocket instance with JSON storage
const pocket = new Pocket({
path: './data/database',
useJson: true
});
// Set a value
await pocket.set('key', 'value');
// Get a value
const result = await pocket.get('key');
console.log(result);
// Delete a value
await pocket.delete('key');API
Pocket(options)
Creates a new Pocket instance.
options(object): Configuration options for the Pocket instance.path(string): The path where the database will be stored.useJson(boolean): Set totrueto use JSON storage, andfalseto use SQLite.
pocket.set(key, value)
Sets a value in the database.
key(string): The key to set.value(any): The value to set.
pocket.get(key)
Gets a value from the database.
key(string): The key to retrieve.
pocket.delete(key)
Deletes a value from the database.
key(string): The key to delete.
pocket.push(key, value)
Pushes a value to an array in the database.
key(string): The key of the array.value(any): The value to push.
