Skip to content

Commit b67867d

Browse files
committed
initial commit
0 parents  commit b67867d

File tree

18 files changed

+7790
-0
lines changed

18 files changed

+7790
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
config

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# README #
2+
3+
This README would normally document whatever steps are necessary to get your application up and running.
4+
Production URL : https://nodejs-task-app.herokuapp.com
5+
6+
### What is this repository for? ###
7+
8+
* Quick summary
9+
* Version
10+
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
11+
12+
### How do I get set up? ###
13+
14+
* Summary of set up
15+
* Configuration
16+
* Dependencies
17+
* Database configuration
18+
* How to run tests
19+
* Deployment instructions
20+
21+
### Contribution guidelines ###
22+
23+
* Writing tests
24+
* Code review
25+
* Other guidelines
26+
27+
### Who do I talk to? ###
28+
29+
* Repo owner or admin
30+
* Other community or team contact

crud.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// CRUD: Create, Read, Update, Delete
2+
const { MongoClient, ObjectId } = require('mongodb');
3+
4+
const connectionURI = "mongodb://127.0.0.1:27017";
5+
const database = "task-manager";
6+
7+
const id = new ObjectId();
8+
//console.log(id);
9+
//console.log(id.getTimestamp());
10+
11+
MongoClient.connect(connectionURI, {useNewUrlParser:true}, (error, client) => {
12+
if(error){
13+
return console.log("Error establishing connection...");
14+
}
15+
16+
const db = client.db(database);
17+
18+
db.collection('users').deleteMany({
19+
age: 31
20+
}).then((result) => {
21+
console.log(result);
22+
}).catch((error) => {
23+
console.log(error);
24+
});
25+
26+
/*db.collection('tasks').updateMany({
27+
completed:false
28+
},{
29+
$set:{
30+
completed: true
31+
}
32+
}).then((result)=>{
33+
console.log(result);
34+
}).catch((error)=>{
35+
console.log(error);
36+
});*/
37+
38+
/*db.collection('users').update({
39+
_id:new ObjectId("5ce293c0511eb823016c9fa0")
40+
},{
41+
$set:{name:"Hardy Wilson"}
42+
}).then((result)=>{
43+
console.log(result);
44+
}).catch((error)=>{
45+
console.log(error);
46+
});*/
47+
48+
/*db.collection('users').findOne({_id:new ObjectId("5ce2917252a5a721aafed448")}, (error, result) => {
49+
console.log(result);
50+
});
51+
52+
db.collection('users').find({age:32}).toArray((error, result) => {
53+
console.log(result);
54+
});*/
55+
56+
/*db.collection('users').insertOne({
57+
_id: id,
58+
name: 'Hardev1 Sharma1',
59+
age: 31
60+
}, (error, result) => {
61+
if(error){
62+
return console.log("Unable to insert document...");
63+
}
64+
console.log(result.ops);
65+
});*/
66+
67+
/*db.collection('users').insertMany([
68+
{name: 'Sunil Kumar', age: 25},
69+
{name: 'Harry', age: 33}
70+
], (error, result) => {
71+
if(error){
72+
return console.log('Unable to insert documents...');
73+
}
74+
console.log(result.ops);
75+
});*/
76+
77+
/*db.collection('tasks').insertMany([
78+
{description: 'House Cleaning', completed: true},
79+
{description: 'Gardening', completed: false},
80+
{description: 'Run Tution Classes', completed: true}
81+
], (error, result) => {
82+
if(error){
83+
return console.log('Data insertion error!');
84+
}
85+
console.log(result.ops);
86+
});*/
87+
});

0 commit comments

Comments
 (0)