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

@samuelpaschalson/json-db

v1.5.0

Published

This is a node_modules package that lets users access or use database like structure with Json files

Downloads

118

Readme

@samuelpaschalson/json-db

This is a package that lets users access or use database like structure with Json files

Fast, unopinionated, minimalist web framework for Node.js.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install @samuelpaschalson/json-db

Features

Model

Schema

Features Summary

const jsondb = require('@samuelpaschalson/json-db');

The jsondb uses a json file as a database, providing user the same experience a mongodb or mysql modules provides them, but while offline. Note this is just the first release, more releases coming soon with more functionalities.

Creates An instance Schema()

Creates a new .Schema() object, it accepts object data using the following parameters. A new _id is generated for each data, but the _id can be replaced by your own _id, a tutorial would be provided below.

new jsondb.Schema({
  name: {
    type: String,
    default: 'john',
    required: true,
    unqiue: true,
    ref: 'User',
  },
});

Accepted object Type For Schema

String, Array, UUID(), Boolean, Number etc [more types coming...]

Creates An instance model()

This creates a model function that enables you run the schema and inserts your data. Some parameters are passed into the model to enable smooth running

jsondb.model(name_of_the_file, Schema_name, json_database_name);

Accepted datas for model

name_of_the_file: this should be the same name as the js file that is the model folder Schema_name: this should be the same name as the schema in the js file json_database_name: this should be a file without a .json extension Note: all three datas should be the same

jsondb.model('User', User, 'user');

API Summary

| | | | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | .save(req.body) | The .save(req.body), saves the posted request to the json database | | .findByIdAndUpdate(req.body, req.param.id) | The .findByIdAndUpdate(req.body, req.param.id), finds the data by the id in the parameters and pushes the req.body to the _id | | .findByIdAndDelete(req.params.id) | The .findByIdAndDelete(req.params.id), deletes the data from the id inserted into the parameter | | .aggregate(pipeline) | The .aggregate performs aggregation operations on the loaded data from the json file based on provided pipelines, check the accepted pipelines below | | .getAll() | This displays all the data in the json file | | .findOne(req.body) | This finds a single object matching the provided query object | | .findById(req.params.id) | This finds a single object matching the provided id |

API

.save(req.body)

For an example checkout the Usage.md

.findByIdAndUpdate(req.body)

For an example checkout the Usage.md

.findByIdAndDelete(req.body)

For an example checkout the Usage.md

.aggregate(pipeline)

For an example checkout the Usage.md

.getAll()

For an example checkout the Usage.md

.findOne(req.body)

For an example checkout the Usage.md

.findById(req.params.id)

For an example checkout the Usage.md

Contact Me

Have a feature or a functionality which you would like to see, send me a message on Gmail [email protected]

3rd party DATABASES

Mysql Support

For an example checkout the Usage.md

Mongoose support coming soon

License

MIT © Samuel Paschalson aka Chinomso Iyasara