🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

whoadb

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whoadb

Store and read JSON objects in a flat file if you want!

latest
Source
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

WhoaDB(!)

Not actually a DB: But read/write JSON objects to/from a flat file using this if you want.

Build
Status

This is a component I extracted from a test REST server used if you're working on a front end app that RESTfully stores data and you want to click around for a little bit without firing up an actual backend.

Starting

npm install whoadb
WhoaDB = require 'whoadb'

persistFile = '/tmp/whoadb.json'

db = new WhoaDB(persistFile)

Finding

record1 = { id: 'fff', name:  "food", _collection: "edibles" }
record2 = { id: 'ggg', name:  "more food", _collection: "edibles" }

db.save(record1)
db.save(record2)

db.all('edibles')

# => [ record1, record2 ]

db.find('edibles', 'fff')

# => record1

Create & Update & Destroy

record = { name:  "food", _collection: "edibles" }

db.save(record)

# record object is assigned an id

record.name = "non-food"

db.save(record)

# record updated

db.destroy(record)

Records without the _collection key

If a record doesn't have a _collection key, it'll be added to the undefined collection.

record1 = { id: 'fff', name:  "food" }

db.save(record1)

db.all(undefined)

# => [ record1 ]

db.find(undefined, 'fff')

# => record1

Keywords

json

FAQs

Package last updated on 27 Nov 2013

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