Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ghostchat-database

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ghostchat-database

A simple, reliable, NoSQL database.

  • 1.0.0-better-readme
  • unpublished
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ghostchat-database

A simple, reliable, NoSQL database.

Documentation

Classes

Database

Methods public get(key: string): Promise - Gets the value of the specified key from the database. public write(key: string,value: any): Promise - Creates a new key. public update(key: string,value: any): Promise - Updates the value of a key. public delete(key: string): Promise - Deletes the key from the database. public list(): Promise - Returns a list of keys in the database. public empty(): Promise - Clears the database.

DBValue

Properties public success: boolean - Whether the interaction was successful or not. public value?: any - The value returned from the interaction.

DBError

extends Error

Properties public message: string - The error message. public errorCode: string - The error code returned from the database.

Guide

This is the guide to using the ghostchat-database module.

First import it using esm import statement

import Database from "ghostchat-database";

Then, create a new instance of the database.

const db = new Database();

Now, lets get a key from the database. We do this with the get function.

db.get("foo")
    .then(({success,value}) => {
        if(!success) console.error(value.message);
        else console.log(value);
    });

If the interaction is not successful, value will be an instance of DBError, if the interaction is a success then value will either be undefined or the data returned from the database (get and list functions).

Now lets write a key

db.write("foo","bar")
    .then(({succes,value}) => {
        if(!success) console.error(value.message);
        else console.log(success); // Value is undefined if success equals true.
    });

If we want to update a key its the same code, just a different function.

db.update("foo","bar")
    .then(({succes,value}) => {
        if(!success) console.error(value.message);
        else console.log(success); // Value is undefined if success equals true.
    });

The write function will error if there is already a key named whats specified. The update function will error if there is no key that matches with the one specified.

FAQs

Package last updated on 20 Feb 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc