New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tinydb

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinydb

tiny json file based datebase for small nodejs projects

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Purpose

TinyDB is a tiny json file based database for NodeJS.
Normally, it's better to use it for your little project.

Features

  • auto save data in memory to local fild after add/delete item;
  • all APIs have a callback function for data handling;
  • name API refering to Mongoose;
  • no third-party dependencies.

Usage

var TinyDB = require('tinydb');
test_db = new TinyDB('./test.db');

test_db.onReady = function() {
  console.log('database is ready for operating');

  // set info to DB
  test_db.setInfo('title', 'Test DB', function(err, key, value) {
    if (err) {
      console.log(err);
      return;
    }
    
    console.log('[setInfo] ' + key + ' : ' + value);
  });
  
  // get info from DB
  test_db.getInfo('title', function(err, key, value) {
    if (err) {
      console.log(err);
      return;
    }
    
    console.log('[getInfo] ' + key + ' : ' + value);
  });
  
  // do other things below
  test_db.forEach(function (err, item) {
    if (err) {
      console.log(err);
      return;
    }

    for (var key in item) {
      console.log(key + ' : ' + item[key]);
    }
  });
}

APIs

.flush(callback)

Write the data in memory to your specified databse file immediately.

.find(query, callback)

Find databse items. query is a object like {_id: "xxxxx"}.

.findById(id, callback)

Find database item by id, equal to .find({_id: id}, callback);

.findByIdAndRemove(id, callback)

Find database item by id and remove it from database.

.insertItem(item, idx, callback)

Insert item to database. idx is optional, default to 0.

.appendItem(item, callback)

Append item to database.

Thanks

Source code of function ._guid() is refering to How to create a GUID / UUID in Javascript?.

Contact

mail : isaymeorg@gmail.com

Keywords

FAQs

Package last updated on 20 May 2014

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