-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.js
More file actions
68 lines (48 loc) · 1.53 KB
/
update.js
File metadata and controls
68 lines (48 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// const mongoose = require('mongoose');
// // Use the same URI as before
// const uri = "mongodb://127.0.0.1:27017/myDatabase";
// mongoose.connect(uri)
// .then(() => console.log("Connected"))
// .catch(err => console.log(err));
// const userSchema = new mongoose.Schema({
// name: String,
// age: Number,
// adds: String
// });
// const User = mongoose.model('User', userSchema);
// const updateUser = async () => {
// try {
// // 1. Filter: Find the user named 'amit'
// // 2. Update: Set the new age to 21
// // { new: true } means "return the updated document, not the old one"
// const updatedUser = await User.findOneAndUpdate(
// { name: 'amit' },
// { age: 21 },
// { new: true }
// );
// console.log("OLD DATA: age was 2");
// console.log("NEW DATA:", updatedUser);
// mongoose.connection.close();
// } catch (error) {
// console.log(error);
// }
// };
// updateUser();
// let sum=require('./sample');
// console.log(sum(5,10));
// let mul=require('./sample');
// console.log(mul(10,5));
// let sub=require('./sample');
// console.log(sub(10,5));
// let {sum,mul,sub}=require('./sample');
// console.log(sub(10,5));
// const express=require("express");
// const app=express();
// app.get("/students",(req,res)=>{
// // res.send("<h1> hello studnets </h1>");
// let data=FileSystem.readFileSync("./data.json",{encoding:"utf-8"});
// res.send(data);
// })
// app.listen(6500,()=>{
// console.log("server is running on port 6500");
// })