-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
23 lines (21 loc) · 807 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require('dotenv').config();
mongoose = require('mongoose'), Vehicle = require('./models/car');
var mongoose = require('mongoose'),
Vehicle = mongoose.model('Vehicles');
const mongourl = process.env.DB_Connection;
const main = async (event) => {
console.log('Event: ' + event);
const {id} = event;
let vehiclePriceHistory = {};
mongoose.Promise = global.Promise;
await mongoose.connect(mongourl,{useNewUrlParser: true}, {useUnifiedTopology: true})
.then(client =>{ console.log("Connection success"); })
.catch(err => console.error('Connection error', err));
return Vehicle.findOne({vehicleID: id}, function(err, task) {
if (err)
return err
console.log(task.pricehistory);
return (task.pricehistory);
});
}
exports.handler = main;