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

@nelson_echeverria/pandadb

v1.0.5

Published

pandadb is a local document-oriented JSON database, ready to be implemented in an application in a simple way

Downloads

22

Readme

pandadb

pandadb is a local document-oriented JSON database, ready to be implemented in an application in a simple way.

it is worth mentioning that the author of panda db was inspired by other packages to develop pandadb, such as lowdb, taffydb among others.

JavaScript Style Guide NPM Version NPM Downloads License: MIT

introduction

pandadb is a local JSON database, which uses a JSON file locally to persist the data, which is managed in a specific application, as a JSON format is used, pandadb uses MQL as a syntax to perform queries, which makes queries more intuitive and friendly to end customers.

example of an MQL query

// should return the element that has the property 'foo', with the value of 'bar'
{ "foo": "bar" }

installation

npm i --save-exact pandadb

usage

[!NOTE] If you do not pass a file name to the PandaDB instance, it will create a JSON file called 'pandadb.json' by default.

const PandaDB = require('pandadb')
const db = new PandaDB('NBA.json') // 

const players = db.collection('players')

players.createMany([
    {
        name: 'Michael Jordan',
        team: 'Chicago Bulls',
        shirtNumber: 23
    },
    {
        name: 'Lebron James',
        team: 'Leakers',
        shirtNumber: 23
    },
    {
        name: 'Kyle Irving',
        team: 'Celtics',
        shirtNumber: 11
    }
]).then(() => console.log('data was created successfully'))

players.find({ shirtNumber: 11 }).then(player => console.log(`here is kyle irving \n ${player}`))

API

All of the following methods listed are available when creating a collection with the 'collection()' method.

  • list obtains/lists all the data of the collection in question
players.list().then(console.log)
  • create creates and automatically inserts an id - UUID for subsequent persistence
const MJ = { name: 'Michael Jordan', team: 'Chicago Bulls', shirtNumber: 23 }

players.create(MJ)
       .then(response => console.log(response)) // { status: 'success', collection: 'players', createdItems: 1 }
  • createMany creates/saves a data set within a collection
players.createMany([
    {
        name: 'Michael Jordan',
        team: 'Chicago Bulls',
        shirtNumber: 23
    },
    {
        name: 'Lebron James',
        team: 'Leakers',
        shirtNumber: 23
    },
    {
        name: 'Kyle Irving',
        team: 'Celtics',
        shirtNumber: 11
    }
]).then(response => console.log(response)) // { status: 'success', collection: 'players', createdItems: 3 }
  • find returns the first element that matches the query
players.find({ team: 'Celtics' }).then(player => console.log('here is Kyle Irving \n', player))
  • findMany will recover all the data that matches the query made
players.findMany({ shirtNumber: 23 }).then(players => console.log('the basketball gods:', players))
  • edit edit the first element that matches the query
players.edit({ name: 'Michael Jordan' }, { retired: true })
       .then(response => console.log(response)) // { status: 'success', collection: 'players', updatedItems: 1 }
  • editMany edit all the elements of a collection that match the query made
players.editMany({ shirtNumber: 23 }, { level: 'god' })
       .then(response => console.log(response)) // { status: 'success', collection: 'players', updatedItems: 2 }
  • remove removes from the collection the first element of the collection that matches the query
players.remove({ shirtNumber: 11 })
       .then(response => console.log(response)) // { status: 'success', collection: 'players', removedItems: 1 }
  • removeMany removes all elements from the collection that match the query
players.removeMany({})
       .then(response => console.log(response)) // { status: 'success', collection: 'players', removedItems: 3 }
  • destroy destroys/removes the collection from which it is called.

[!IMPORTANT] the methods can still be accessed, but they will have no effect

players.destroy().then(() => console.log('the players collection was eliminated'))
players.list() // undefined

license

pandadb is under the MIT license