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

docdb

v0.0.6

Published

crossplatform NoSQL JS database

Downloads

40

Readme

DocDB

LOG-based JavaScript DataBase (based on streaming processing). The API will be significantly changed.

Install

	npm i docdb --save

Use

	const DATASTORE = require('docdb');
	let DataBase = new DATASTORE({dbname:'_test'});
	DataBase.then(function(db){
		
		//warning stream
		db.on('data', function(buffer){
			console.log(buffer);
		});
		
		//find documents from database (if you use the _id key, the search is performed by index)
		db.findMany({..filter documents fields type of Object}, [..document fields returned type of Array]).then(function(arr){
			//query result type of Array
			console.log(arr);
		});
		
		//insert (or update if exists) one document from database
		db.insertOne({..insert document type of Object}).then(function(_id){
			console.log(arr);
		});
		
		//remove one document from database
		db.removeOne({_id: first key document type of String}).then(function(_id){
			console.log(arr);
		});
		
		//backup database files
		db.service.toBackup().then(function(){
		
		});
		
		//restore database files from backup
		db.service.fromBackup().then(function(){
			
		});
		
		//recovery index file
		db.service.recovery().then(function(){
			
		});
		
		//index file compression
		db.service.compact().then(function(){
			
		});
		
		//data file compression
		db.service.compact("log").then(function(){
			
		});
	});

EXAMPLE

	const DATASTORE = require('docdb');
	let DataBase = new DATASTORE({dbname:'test'});
	DataBase.then(function(db){
		
		//warning stream
		db.on('data', function(buffer){
			console.log(buffer);
		});
		
		//insert (or update if exists) one document from database
		db.insertOne({_id: "sdasdasdas", text:"test", data: Date.now()}).then(function(_id){
			console.log(_id);
			return new Promise(function(res, rej){	//find documents from database (if you use the _id key, the search is performed by index)
				setTimeout(function(){
					db.findMany({_id: "sdasdasdas"}, ["_id", "text"]).then(res).catch(rej);
				}, 100);
			});	
		}).then(function(arr){
			//query result
			console.log(arr);
			return db.removeOne({_id: "sdasdasdas"});	//remove one document from database
		}).then(function(_id){
			console.log(_id);
			return new Promise(function(res, rej){	//find documents from database (if you use the _id key, the search is performed by index)
				setTimeout(function(){
					db.findMany({_id: "sdasdasdas"}, ["_id", "text"]).then(res).catch(rej);
				}, 100);
			});	
		}).then(function(arr){
			console.log(arr);
			return db.service.toBackup();//backup database files
		}).then(function(bool){
			console.log(bool);
			return db.service.fromBackup();//restore database files from backup
		}).then(function(bool){
			console.log(bool);
			return db.service.recovery();//recovery index file
		}).then(function(bool){
			console.log(bool);
			return db.service.compact();//index file compression
		}).then(function(){
			return db.service.compact("log");//data file compression
		}).then(function(){
			console.log('Test complete!');
		}).catch(function(err){
			console.log('Test interrupted, with error:', err);
		});
	});

EXAMPLE CONSOLE

	let READLINE = require('readline'),
		DATASTORE = require('docdb');
		
	let DataBase = new DATASTORE({dbname:'test'});

	DataBase.then(function(db){
		db.on('data', function(buffer){
			console.log(buffer);
		});
		const rl = READLINE.createInterface({
			input: process.stdin,
			output: process.stdout,
			prompt: 'DocDB> '
		});
		rl.prompt();
		rl.on('line', (line) => {
			try{
				let _tmp = eval(line);
				if(typeof(_tmp) !== 'undefined'){
					console.log(_tmp);
				}
			} catch(err) {
				console.error("Ошибка команды: "+err);
			}
			rl.prompt();
		}).on('close', () => {
			console.log('DocDB disconnected!');
			process.exit(0);
		});
	});

LICENSE

Apache-2.0