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

bucky.db-local

v1.2.1

Published

An npm that creates a local database in your json project

Downloads

18

Readme

Installation:

npm install bucky.db-local --save

yarn add bucky.db-local

Important informations:

  • This npm uses node v16.6.0 or higher, another version below this may result in unexpected errors.
  • To better understand how to use the functions, take a good look at the examples below the list of available functions!
  • All npm functions have the option for you to use a callback return, it is not mandatory.
  • The set, update, delete and push functions have a function called “save”, if you do not use this function, the data will only be in the database cache, to save, just run the function.

Setting up database:

There are two ways to configure:

const
  { Database } = require('bucky.db-local'),
  db = new Database({
    // [...]
  });

// Or

const
  { Database, Config } = require('bucky.db-local'),
  db = new Database(new Config({
    // [...]
  }));

Options to configure:

| Name | Description | Default | | ---- | ----------- | ------- | | directory | File path where the database should be. | ./Database.json | | objectNotation | Define which object notation. | / | | Serialize | You can use this function to encrypt information. | false | | Deserialize | You can use this function to decrypt the information. | false | | Defaults | When the database is created, it will be created with these values. | false |

Functions:

| Name | Params | | ------ | -------- | | set | path values callback | | get | path callback | | update | path values callback | | delete | path callback | | push | path values callback | | has | path callback | | all | path callback | | keys | path callback | | values | path callback | | entries | path callback | | toJSON | path callback |

Examples:

Set:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
let data = db.set('db', 'local');

// It will show the data information along with a function called "save".
// If you don't use the save function, the data will be saved in the cache.
console.log(data);

console.log(data.save()); // Output: true. Value: Boolean

Get:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
db.set('db', 'local').save();
let data = db.get('db');
console.log(data); // Output: local

Update:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
db.set('db', { type: 'local' }).save();
let data = db.update('db', { name: 'bucky.db-local' });
console.log(data.dataValues); // { db: { type: 'local', name: 'bucky.db-local' } }
console.log(data.save()); // Output: true

Delete:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
db.set('db', { name: 'bucky.db-local', type: 'local' }).save();
let data = db.delete('db/name');
console.log(data.save()); // Output: true

Push:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
let data = db.push('db', [{ type: 'local' }, { name: 'bucky.db-local' }]);
console.log(data.dataValues); // Output: { db: [ { type: 'local' }, { name: 'bucky.db-local' } ] }
console.log(data.save()); // Output: true

Has:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
let data1 = db.has('db');

db.set('db', 'local').save();
let date2 = db.has('db');

console.log(data1); // Output: false
console.log(data2); // Output: true

All:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
let data = db.all();
console.log(data); // It will show all values from your database.

Keys:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
db.set('db', { name: 'bucky.db-local', type: 'local' });
let data = db.keys('db');
console.log(data); // Output: [ 'name', 'type' ]

Values:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
db.set('db', { name: 'bucky.db-local', type: 'local' });
let data = db.values('db');
console.log(data); // Output: [ 'bucky.db-local', 'local' ]

Entries:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
db.set('db', { name: 'bucky.db-local', type: 'local' });
let data = db.entries('db');
console.log(data); // Output: [ [ 'name', 'bucky.db-local' ], [ 'type', 'local' ] ]

ToJSON:

const
  { Database } = require('bucky.db-local'),
  db = new Database();
  
db.set('db', { name: 'bucky.db-local', type: 'local' });
let data = db.toJSON('db');
console.log(data); // Output: {"name":"bucky.db-local","type":"local"}