You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
940 B
45 lines
940 B
// log.js
|
|
// Copyright (C) 2022 DTP Technologies, LLC
|
|
// License: Apache-2.0
|
|
|
|
'use strict';
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
const Log = mongoose.model('Log');
|
|
|
|
const { SiteService } = require('../../lib/site-lib');
|
|
|
|
class SystemLogService extends SiteService {
|
|
|
|
constructor (dtp) {
|
|
super(dtp, module.exports);
|
|
}
|
|
|
|
async getRecords (search, pagination) {
|
|
const logs = await Log
|
|
.find(search)
|
|
.sort({ created: -1 })
|
|
.skip(pagination.skip)
|
|
.limit(pagination.cpp)
|
|
.lean();
|
|
return logs;
|
|
}
|
|
|
|
async getComponentIds ( ) {
|
|
return await Log.distinct('component.logId');
|
|
}
|
|
|
|
async getTotalCount ( ) {
|
|
const count = await Log.estimatedDocumentCount();
|
|
this.log.debug('log message total count', { count });
|
|
return count;
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
logId: 'svc:log',
|
|
index: 'log',
|
|
className: 'SystemLogService',
|
|
create: (dtp) => { return new SystemLogService(dtp); },
|
|
};
|