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

informa-db.js

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

informa-db.js

DataBases made easier

  • 1.0.9
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Informa-Db.js

All Contributors

Concept

The concept is to interact with storage units (such as Dbs or JSON files) by using javascript proxies.

How to install it:

npm i --save informa-db.js

How to use it:

Here's a code example on how to use it:

const {LocaleDb} = require('informa-db.js'); // Require the package

const players = new LocaleDb("players.json"); // Uses data.json to store data
// I implemented these functions but they're boring:
if (!players.exist(process.env.PLAYER))
  players.add(process.env.PLAYER,{
    inventory: Array(20),
    equipment: Array(5),
    temporaryData: {
      hp: 20,
      xp: 0
    }
  });
// Instead, use this more elegant way of doing it:
if(!players.value[process.env.PLAYER])
  players.value[process.env.PLAYER]={
    inventory: Array(20),
    equipment: Array(5),
    temporaryData: {
      hp: 20,
      xp: 0
    }
  };

Before you ask, those all work.

Docs

new LocaleDb( options{path, defaultString} )

options.path

Path to file. Will throw an error if none provided or if type is incorrect

options.defaultString

Default string to write on file if it doesn't exist. Defaults to '{}'

new RemoteDb( options{path, db, collection} )

options.path

URI to mongo db server. Will throw an error if none provided or if type is incorrect Boolean indicating whether the provided path is a file or a mongodb server Defaults to true if the path starts with "mongodb", false otherwise.

Notice: If you need to interact with a mongodb server, you need to install mongodb yourself

options.db

Database name, defaulting to "db"

options.collection

Collection name, defaulting to "collection"

Contributors ✨

Thanks goes to these wonderful people (emoji key):


informathemusic

💻

Haouari haithem

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

FAQs

Package last updated on 29 Jul 2020

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