adding loading historical data on server start
This commit is contained in:
parent
083e8e0d35
commit
0d47ae3efe
9
index.js
9
index.js
@ -169,6 +169,15 @@ function loadHistoricToDb() {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
// run loadHistoricToDb() only once when the server starts and no data is present in the database
|
||||
PriceHistory.countDocuments({}, (err, count) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
if (count === 0) {
|
||||
loadHistoricToDb();
|
||||
}
|
||||
})
|
||||
|
||||
app.get("/price-history", async (req, res) => {
|
||||
try {
|
||||
|
||||
2
index.min.js
vendored
2
index.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user