forked from dearle/recrac
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinsertData.js
37 lines (32 loc) · 992 Bytes
/
insertData.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
const env = require('node-env-file');
env(__dirname + '/.env');
const data = require('./data.json');
const Event = require('./models/event');
const db = require('./db');
const insertData = function() {
data.forEach((item) => {
const newEvent = new Event({
name: item.name,
description: item.description,
host: item.host,
type: item.type,
location: { address: item.location.address, lng: 0, lat: 0 },
desiredParticipants: item.desiredParticipants,
time: item.time,
price: item.price,
confirmedParticipants: item.confirmedParticipants,
potentialParticipants: item.potentialParticipants,
rating: item.rating,
rateAmount: item.rateAmount,
ratingParticipants: item.ratingParticipants
});
newEvent.save(function (err, newEvent) {
if (err) {
console.error('Error is ', err);
return handleError(err);
}
console.log('Success: ', newEvent);
});
});
};
insertData();