Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
3 changes: 3 additions & 0 deletions Full Stack Webdevlopment/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
10 changes: 10 additions & 0 deletions Full Stack Webdevlopment/MongoDB/tut81.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

//CRUD operations

//create
// Inserting data in mongo db
use harryKart

db.items.insertOne({name: "Samsung 30s", price: 22000, rating: 4.5, qty: 233, sold: 98})

db.items.insertMany([{name: "Samsung 30s", price: 22000, rating: 4.5, qty: 233, sold: 98}, {name: "Moto 30s", price: 29000, rating: 3.5, qty: 133, sold: 598}, {name: "Realme 80s", price: 129000, rating: 2.5, qty: 633, sold: 98, isBig: true}])
23 changes: 23 additions & 0 deletions Full Stack Webdevlopment/MongoDB/tut82.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

//searching for data in mongo db
use harrykart

// Read
// the query will return all the object with rating equal to 3.5
db.items.find({rating:3.5});
db.items.find({rating: {$gte:4.0}})
db.items.find({rating: {$gt:4.0}})


// and operator
db.items.find({rating: {$gt:4.0},price:{$gt:25000}})
db.items.find({rating: {$lt:4.0},price:{$gt:114000}})


// or operator
db.items.find({$or:[{rating:{$lt:4.5}},{price:{$gt:30000}}]})


// perticular data filtering
db.items.find({rating:{$gt:3.5}}, {rating:1});
db.items.find({rating:{$gt:3.5}}, {rating:1,qty:1});
16 changes: 16 additions & 0 deletions Full Stack Webdevlopment/MongoDB/tut83.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

//DELETE
show dbs
show harrykart
show collections

db.items.find()

db.items.find({price:22000})

//deleting items from the mongo DataBase
db.items.deleteOne({price:22000})


// deletOne will delete the matching entry and will delete the first entry in case of multi document match
db.items.deleteMany({price:22000})
30 changes: 30 additions & 0 deletions Full Stack Webdevlopment/MongoDB/tut84.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

// show the database
show dbs

// use the harrykart database
use harrykart

// how to create database
use newDB

// show database items
show harrykart

// show the harrykart collections
show collections

// show the all items
db.items.find()


// update the one object
db.items.updateOne({name:"Samsung 30s"},{$set:{price : 2}})
db.items.find()


// update the many object
db.items.updateMany({name:"Samsung 30s"},{$set:{rating : 2}})
db.item.find()


16 changes: 16 additions & 0 deletions Full Stack Webdevlopment/MongoDB/tut85.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

/*
// mongoose is helping directly use in the nodejs

// mongoDB Compass
pehale hum mongoSell used karate the bad me hum MongoDB Compass use karate hai.

// mongod -> main database process hai
-> we can connect any thing(nodejs, python, php, mongoose) with mongod

ODM ->open document modling


mongod is server and mongo is clinet

*/
76 changes: 76 additions & 0 deletions Full Stack Webdevlopment/MongooseTutorial/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

// getting-started.js
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/harrykart', { useNewUrlParser: true, useUnifiedTopology: true });


const db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {

// we're connected!

//console.log("We are connected bro/sis...");


});

// schema is layer. it is top of mongoDB. validation, which data going to the database is control using schema.
const kittySchema = new mongoose.Schema({
name: String
});


// speak method add
kittySchema.methods.speak = function () {
const greeting = "Meow name is " + this.name;
console.log(greeting);
}


// kittySchema is converting model Kitten
// Schema me kosi fild kya rahegi aor
// model is final complite Schema
// schema is converting model
const Kitten = mongoose.model('ParthKitten', kittySchema);


const harryKitty = new Kitten({ name: 'harryKitty' });
const harryKitty2 = new Kitten({ name: 'harryKitty2' });
//console.log(harryKitty.name); // 'harryKitty'
//harryKitty.speak();

/*
output:

harryKitty Name
Meow name is harryKitty Name
We are connected bro/sis...

we are connected bro/sis. badame run horaha hai koyki
nodejs nonblocking (ayscronoustion)
*/

/*
two parameter:
1->error
2->harryKitty(objct)

this is save in to the harrykart database
*/
harryKitty.save(function (err, harryKitty) {
if (err) return console.error(err);
harryKitty.speak();
});


harryKitty2.save(function (err, harryKitty2) {
if (err) return console.error(err);
//harryKitty2.speak();
});


Kitten.find({ name: "harryKitty2" }, function (err, kittens) {
if (err) return console.error(err);
console.log(kittens);
})
15 changes: 15 additions & 0 deletions Full Stack Webdevlopment/MongooseTutorial/node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading