-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestdb.js
44 lines (37 loc) · 936 Bytes
/
testdb.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
// use this as a template for your db files
// replace the 'roomsplitdb' with more specific db names
// dont forget to run mongod
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
mongoose.connect('mongodb://localhost/roomsplitdb');
mongoose.connection.once('open', (err) => {
if (err) console.log('there was an error connecting to db!');
console.log('Connected with roomsplit DB');
});
const testSchema = new Schema({
id: String,
userName: String,
password: String
});
const Test = mongoose.model('test', testSchema);
new Test({
id: 1,
userName: 'epark',
password: 'password'
}).save((err) => {
if (err) console.log('issue with 1');
});
new Test({
id: 2,
userName: 'kpark',
password: 'password'
}).save((err) => {
if (err) console.log('issue with 2');
});
new Test({
id: 3,
userName: 'cpark',
password: 'password'
}).save((err) => {
if (err) console.log('issue with 3');
});