Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongodb.json

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

mongodb.json

fast database with json extends mongoose style

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-57.14%
Maintainers
1
Weekly downloads
 
Created
Source

mongodb.json - App success made simple

fast database with json extends mongoose style

Installing

$ npm init
$ npm install --save mongodb.json

fast database with json extends mongoose style

#setup

 const mongooseJson = require("mongodb.json") // mongooseJson it is the class of the package
 
 const usersSchema = { // normal javascript object and its the schema
    name: String, // String it is the type of the key
    age: Number, // Number it is the type of the key
    nickname: String, // String it is the type of the key
    password: String || Number 
}

const usersModel = new mongooseJson({
 path: "database.json" // its the file name
 dir: "database" // the dir of database.json file
}, usersSchema /* schema varible*/ ) 

how to create a new Data

async function createData() {
 const data = usersModel.findOneOrCreate({name: "hello"}) // -> {"name": "hello"}
}

how to find Data

async function findData() {
 const data = usersModel.findOne({name: "hello"}) 
 console.log(data) // -> {"name": "hello", id: "......"}
}

how to edit or add property

async function save() {
 const data = usersModel.findOne({name: "hello"}) 
 data.name = "ziad"
 data.password = 13313193201e
 data.nickname = "ziath"

 data.save()
}

how to delete data

async function delete() {
 const data = usersModel.findOne({name: "hello"}) 
 data.delete()
}

all current methods

methodsDescription
findOnefind element
createcreate new Object
fetchget all data
findOneOrCreatefind data or create new one

dev

Ziath#1768

Keywords

FAQs

Package last updated on 24 Dec 2022

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