-
Notifications
You must be signed in to change notification settings - Fork 1
/
seeds.js
43 lines (39 loc) · 938 Bytes
/
seeds.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
var mongoose = require("mongoose");
var User = require("./models/userSchema");
var data = [
{
firstName: "David",
lastName: "Jones",
username: "davidjo012",
password: "12345",
phone:"9336108567",
email:"[email protected]",
avatar:"https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/800px-Image_created_with_a_mobile_phone.png",
address:"462 Adams Drive",
state: "Uttar Pradesh",
city: "Kanpur",
zip:"207009",
role:"Patient",
gender:"Male",
}
]
function seedDB(){
User.deleteMany({},function(err){
if(err)
console.log(err);
else{
console.log("Removed Users !!");
//add a user manually
data.forEach(function(seed){
User.create(seed,function(err,user){
if(err)
console.log(err);
else{
console.log("Added a user");
}
});
});
}
});
}
module.exports = seedDB;