1.1.0 • Published 2 years ago

my-pocket.db v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Pocket

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.db

Usage

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 to true to use JSON storage, and false to 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.
1.1.0

2 years ago

1.0.0

2 years ago