-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamicRegistrationSchemaDescription.js
86 lines (81 loc) · 1.99 KB
/
dynamicRegistrationSchemaDescription.js
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
// require mongoose
var mongoose = require('mongoose');
var descriptionschema = mongoose.Schema({
// storing the data according to considering the single user
key: {
type: String,
required: true
},
// user form data will be stored in this values and for single user number of forms can in stored here
values:[{
// user / creator name
creatorName: {
type: String,
required: true
},
// form name
formName: {
type: String,
required: true
},
// form description
formDescription: {
type: String,
required: true
},
// form generating date
formgeneratedDate: {
type: String,
required: true
},
// creating of a form data
formgeneratedData: [{
_id: {
type: String,
required: true
},
text: [{
_id: {
type: String
}
}],
textarea: [{
_id: {
type: String
}
}],
button: [{
_id: {
type: String
}
}],
checkbox: [{
_id: {
type: String
}
}],
select: [{
_id: {
type: String
}
}]
}]
}]
});
var descriptionmodel = module.exports = mongoose.model('descriptionmodel', descriptionschema);
// updating/creating description data in to the table
module.exports.createData = function(data, callback) {
descriptionmodel.create(data, callback);
}
//finding formname already exists or not
module.exports.findformnamedata = function(data, callback) {
descriptionmodel.findOne({key : data.username}, callback);
}
module.exports.updatedatatoexistinguser = function(data, callback) {
var insertiondata = data.mainsetdata[0];
descriptionmodel.update({key: data.key}, {$addToSet: {values: insertiondata}}, callback);
}
// updating a table information for already existed user createdatauser
module.exports.findandaddusernamedata = function(data, callback) {
descriptionmodel.findOne({key : data.key}, callback);
}