You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
683 B
JavaScript
21 lines
683 B
JavaScript
import Visits from "../models/Visits.js";
|
|
import ApiError from '../controllers/ErrorController.js';
|
|
|
|
class VisitService {
|
|
|
|
async getAll() {
|
|
const visits = await Visits.find();
|
|
const allTime = visits.find(item => item.name === 'alltime');
|
|
const month = visits.find(item => item.name === 'month');
|
|
const day = visits.find(item => item.name === 'day');
|
|
const lastday = visits.find(item => item.name === 'lastday');
|
|
|
|
return { allTime, month, day, lastday};
|
|
}
|
|
async update() {
|
|
await Visits.updateMany({name: {$ne: 'lastday'}}, { $inc: { count: 1 } });
|
|
return 'ok';
|
|
}
|
|
}
|
|
|
|
export default new VisitService(); |