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

connection-to-mongodb

v1.0.0

Published

### insallation

Downloads

5

Readme

CONNECT-TO-MONGODB IS A NODE.JS MODULE (PACKAGE) WHICH MAKE EASY CONNECT WITH MONGO-BD AND PERFORM READ , WRITE , UPDATE , DELETE QUERY IN MOMGO-BD

INSTALLATION :-

npm i connection-to-mongodb

IMPORT IN YOUR PROJECT : -

const mongodb = require('connection-to-mongodb');

INISLIZE THE MODULE :-

//root directory path of your project 
const rootDir = process.cwd() ;

// mongoDB path on local system ;
const mongoPath = 'mongodb://localhost:27017/mydbname' ;

const db = mongodb( rootDir , mongoPath );

HOW TO USE :-

 After inislize the module run the app 
 node myapp.js 
 Now database directory created in root  directory of your app.
 Go to database directory and create new file yourDocument.js and write documet structure 
according to the example  
// document structure for a contact form 
const contact = () => {
    return {
        // your document structure here ... 
        name:String,
        email:String,
        mobile:String ,
        message:String ,
    }
 }
 module.exports = contact;
FOR WRITE THE DOCUMENT IN MONGO-BD :-
//for write the document ;
const collationName = 'contactForm' ;
const data = {
          name:'name',
          email:'user email id',
          mobile:'user mobile number',
          message:'user massage',
}
const data =  db.Write(collationName , data ) ;
FOR READ THE DOCUMENT IN MONGO-BD :-
//for read the document ;
const collationName = 'contactForm' ;
const filter        = {  name:'name' }
const data =  db.Read(collationName , filter ) ;
FOR UPDATE THE DOCUMENT IN MONGO-BD :-
//for update the document ;
const collationName = 'contactForm' ;
const filter        = {  name:'name' } ;
const updatevalue   = {
                      email:'user new email id',
                      mobile:'user new mobile number',
 }
const data =  db.Update(collationName , filter , updatevalue ) ;
FOR DELETE THE DOCUMENT IN MONGO-BD :-
//for delete the document ;
const collationName = 'contactForm' ;
const filter        = {  name:'name' } ;
const data =  db.Delete(collationName , filter ) ;

EXAMPLE CODE : -

DOCUMENT STRUCTURE FOR THIS EXAMPLE WHICH WRITE IN DATABASE DIRECTORY ( FILE-NAME = contactFrom.js ) : -
const contacForm = () => {
             return{
                 name:String,
                 email:String,
                 mobile:String ,
                 message:String ,
             }      
}
module.exports = contacForm ;
const express = require('express');
const mongo = require('connect-to-mongodb');
const app = express();

//root directory path of your project 
const rootDir = process.cwd() ;
// mongoDB path on local system ;
const mongoPath = 'mongodb://localhost:27017/mydbname' ;
const db = mongo( rootDir , mongoPath );

// for read data from mongodb ;
app.get('/get' , async (req , res) => {
    // read data from database ;
    const filter = { name : "name of uer which you find"}
    const data = await db.Read('contactForm' , filter);
    res.send(data);
});

//for write document in mongodb 
app.get('/write' , async(req ,res) => {
     const UserData = {
         name:'mahender',
         email:'user email id',
         mobile:'user mobile number',
         massage:' hello connect-to-mongodb '
    };

    const Status = await db.Write('contactForm' , UserData);
    res.send(Status);
});

//for update document in mongodb
app.get('/update' , async(req ,res) => {
     const filter = {name:"user name which you update"} ;
     const updatevalue = {  mobile:'user new mobile number', };

   const Status = await db.Update('contactForm' , filter , updatevalue);
   res.send(Status);
});

app.get('/delete' , async(req ,res) => {
    const filter = { name: "user name which your delete"}
    const Status = await db.Delete('contactForm' filter ,});
    res.send(Status);
 });

app.listen(300 , () => {
    console.log('server start at 300')
})

FOR MORE INFO CONNECT WITH ME

FACEBOOK :

https://www.facebook.com/MJ-Web-Creations-105183487971567/?ref=pages_you_manage

INSTAGRAM : https://www.instagram.com/mahenderajput1/

YOUTUBE : -

https://www.youtube.com/channel/UCTGDmAfBk7872dIIXy4jQ1w

GITHUB : -

https://github.com/mahender214471/