npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

filedb

v1.1.1

Published

A simple Nodejs file system database for prototyping and learning NoSql database concepts

Downloads

21

Readme

fileDB documentation.

Author

Ajah, Chukwuemeka

Contacts

chukwuemekaajah on npmJS chukwuemekaajah on github

Install

$ npm install fileDB

Usage

This is a library that implements a file system database that is entirely built with Javascript and stores data in designated files as JSON format data. It can be used for prototyping when building web apps with nodeJS on a remote server.

Motivation for the Library

This library was built by a beginner JavaScript developer so as to learn how to use databases to interact with my nodeJS web app and as well contribute my own quota to the open source community and as well help beginner JavaScript developers learn how to use databases thereby preparing them for learning NoSql databases like MongoDB.

Documentation

To create an instance of the database:

var db = require('fileDB');
db = new db();

To create a connection to the database:

db.createConnection('filename',callback);
 This creates a new file database in JSON format if it does not exist or instantiates the database if it is already a well-formatted JSON file.
 The optional callback can be used to perform any action as the creation of the database returns true if the database was created.

To save a document to the database.

db.save('collection','document',callback);
 This saves a document which is in JavaScript object format and saves it in the specified collection array. It returns true if the document is 
 successfully  saved and the return value which is a boolean can be utilized by the callback to carryout any specified action.	
example: db.save('books',{name:'Things fall apart',author:'Chinua Achebe'},function(val){if(val) console.log('document successfully saved'); else console.log('something went wrong');});

To update a document in the database.

db.update('collection','newDocumentValues',callback);
 This updates all the documents in the given collection with the new values specified in the newDocumentvalues argument and returns a boolean to the callback.
example: db.update('books',{name:'AntHills of the Savannah',author:'Chinua Achebe'},function(bool){ if(bool) console.log('update done') else console.log('unsuccessful');});

To find documents in a database.

db.find('collection','conditions',callback);
 This finds all the documents in the given collection of the database that satisfies the given the conditions and the conditions argument is an array of 
 desired properties to be satisfied by the documents. It returns an array of documents that satisfy the given conditions.
example: db.find('collection',['name','author'],function(results){ if(results) console.log(results); else console.log('there are no documents that satisfy the conditions');});

To remove documents from a database.

db.remove('collection','conditions',callback);
 This finds all the documents in the collection of the database that satisfies the given conditions and the conditions argument is an array of specifications
 and then removes all the documents that satisfy the given condition. It returns true if the process is successful.
example: db.remove('books',['name','author'],function(bool) { if(bool) console.log('successful'); else console.log('unsuccessful');});

To aggregate the number of documents in a collection.

db.aggregate('collection','conditions',callback);
 This aggregates the number of documents in the given collection and returns the value to the callback to utilize in any activity. It checks to see if the collection
 exists first before returning the number of documents.
example: db.aggregate('books',['name','author'],function(value){ console.log(value);});

All of the functions except save and aggregate have another form of it whereby only one value is acted upon. Other functions are:

db.findOne('collection','conditions',callback);
db.updateOne('collection','conditions',callback);
db.removeOne('collection','conditions',callback);

'# fileDB'