-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
123 lines (82 loc) · 2.83 KB
/
app.js
File metadata and controls
123 lines (82 loc) · 2.83 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// to controll ur website
const express = require("express");
const app = express();
const port = 4000;
const mongoose = require("mongoose");
// mongoooose
mongoose
.connect(
"mongodb://127.0.0.1:27017/FormDB"
)
.then(() => console.log("Connecting to DB....."))
.catch((e) => console.error("Could not to connect to mongoDB...", e));
require("./Model/Schema");
const formRoute = require('./routes/form');
app.set("view engine", "ejs");
app.use(express.json());
app.use(express.static("public"));
app.use(express.urlencoded({ extended: true }));
app.use("/form" , formRoute);
app.listen(port,()=> {console.log("listen to port............")})
////////////////////////////////////////////////////////////////////////////////////////////////////////
// async function saveForm(Title, ispublished) {
// let form = new Form({
// Title,
// ispublished,
// });
// //form.update({ $push: { Questions: Question._id } });
// await form.save();
// }
// async function SaveQuestion(Content, Type) {
// const Question = new Questions({
// Content,
// Type,
// });
// await Question.save();
// }
// async function addQuestion(Formid, ques) {
// await Form.findByIdAndUpdate(Formid, { $push: { Questions: ques } });
// }
// async function CreateUser(Name, Email, phonenumber) {
// const User = new Users({
// Name,
// phonenumber,
// Email,
// });
// await User.save();
// }
// async function addFormToUser(userid, formid) {
// await Users.findByIdAndUpdate(userid, {
// $push: { Form: formid },
// });
// }
// async function CreateAnswer(content, userid) {
// const answer = new Answer({});
// await answer.save();
// await answer.update({
// $set: {
// Content: content,
// },
// $push: {
// User: userid,
// },
// });
// }
//let ans = [{Ques :'640ddee21a76f9319f69e195' , Ans :'25'} , {Ques :'640ddee21a76f9319f69e195' , Ans :'25'} , {Ques :'640ddee21a76f9319f69e195' , Ans :'25'}];
// ans.forEach(element => {
// console.log(element);
// });
//CreateAnswer(ans , '640dfe2c9e6f2858fa643e6c');
//CreateAnswer("germany1966", "64109e067ec78c137aa8203d")
// CreateUser('Ahmed' , 'Ahmed@gmail.com' , '011254554');
// CreateUser('kok' , 'kimmmmmm@y.com' , '9111125');
// CreateUser('hh' , 'uiu@y.com' , '8789');
//CreateUser('abdo' , 'abdo@y.com' , '0008456');
//addFormToUser('640dfe2c9e6f2858fa643e6c',['640ddf11cea07e55efd886fc']);
//addFormToUser("64109e067ec78c137aa8203e", "6410ab7fd768edbfa37c8849");
//addFormToUser("64109e067ec78c137aa8203e", "64109e067ec78c137aa82040");
//addQuestion('form' , ['qid' , '640ddee21a76f9319f69e194']);
//addQuestion("6410ab7fd768edbfa37c8849", ["qid", "6410a372358376e0e2b0c04f" ] )
//SaveQuestion('How R YA' , 'TextQ');
//SaveQuestion('How old are you' , ' Text');
//saveForm("Application hirring Devs" , false );