newStaffLDB-API #48

Merged
fred.boniface merged 85 commits from newStaffLDB-API into main 2023-10-03 21:35:03 +01:00
1 changed files with 9 additions and 8 deletions
Showing only changes of commit 1805040f93 - Show all commits

View File

@ -14,9 +14,7 @@ const db = client.db(dbName);
async function query(collection, query, returnId = false) {
await client.connect();
logger.trace(
`dbAccess.query: Connecting to collection: '${collection}'`
);
logger.trace(`dbAccess.query: Connecting to collection: '${collection}'`);
var qcoll = db.collection(collection);
var qcursor = qcoll.find(query);
if (!returnId) {
@ -34,7 +32,10 @@ async function queryProject(collection, query, projection) {
logger.debug(`dbAccess.queryProject: Connecting to col: '${collection}'`);
const qcoll = db.collection(collection);
const qcursor = qcoll.find(query).project(projection);
logger.debug(projection, `dbAccess.query: Running Query: ${JSON.stringify(query)}`)
logger.debug(
projection,
`dbAccess.query: Running Query: ${JSON.stringify(query)}`
);
increment(collection);
return await qcursor.toArray();
}
@ -48,9 +49,7 @@ async function queryAggregate(collection, pipeline) {
}
async function increment(target) {
logger.debug(
`dbAccess.increment: Incrementing counter for: ${target}`
);
logger.debug(`dbAccess.increment: Incrementing counter for: ${target}`);
await client.connect();
let col = db.collection("meta");
let update = {};
@ -102,7 +101,9 @@ async function delRegReq(uuid) {
}
async function colCount(collection) {
logger.debug(`dbAccess.colCount: Counting entries in collection: ${collection}`);
logger.debug(
`dbAccess.colCount: Counting entries in collection: ${collection}`
);
await client.connect();
let col = db.collection(collection);
let count = col.countDocuments();