-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
61 lines (55 loc) · 1.86 KB
/
app.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
var mongooseInstance;
var mongooseConnection;
var dbvar;
module.exports = {
connect: function(data) {
/* mongooseConnection = Mongoose.connection;
mongooseConnection.once('open', () => {
console.log('Connected to its me.');
});
mongooseInstance = Mongoose.connect("mongodb://localhost:27017/uses-tracking");*/
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ObjectId = Schema.ObjectId;
mongoose.connect('mongodb://localhost:27017/uses-tracking');
var db = mongoose.connection;
var dbCollection = db.collections;
var factory = new Factory(Schema,mongoose);
factory.createSchemas(data);
},
insertIntoDB: function(){
console.log('mongoose mongooseInstance '+mongooseInstance);
console.log('mongooseConnection data'+mongooseConnection);
},
};
var Factory = function(Schema,mongoose) {
this.Schema = Schema;
this.mongoose = mongoose;
this.Item = null;
this.createSchemas = function(data) {
console.log("Is in CreateSchemas")
var PersonSchema = new this.Schema({
first_name: String,
last_name: String,
city: String,
state: String
});
this.Person = mongoose.model('Person',PersonSchema);
this.Person.create(data,function(error,output) {
console.log("Inserted Successfully..");
console.log(JSON.stringify(output));
});
};
this.getPerson = function(query,res) {
this.Person.find(query,function(error,output) {
res.json(output);
});
};
this.doLogin = function(query,res) {
this.Person.findOne(query,function(error,output) {
console.log(query);
res.json(output);
console.log(output);
});
};
};