newStaffLDB-API #48
@ -16,16 +16,16 @@ const db = client.db(dbName);
|
||||
|
||||
async function query(collection, query, returnId = false) {
|
||||
await client.connect();
|
||||
logger.logger.debug(`dbAccess.query: Connecting to collection: '${collection}'`)
|
||||
logger.logger.trace(`dbAccess.query: Connecting to collection: '${collection}'`)
|
||||
var qcoll = db.collection(collection);
|
||||
var qcursor = qcoll.find(query);
|
||||
if (!returnId) {
|
||||
qcursor.project({ _id: 0 });
|
||||
}
|
||||
logger.logger.debug(query, "dbAccess.query: Runnung Query")
|
||||
logger.logger.trace(query, "dbAccess.query: Runnung Query")
|
||||
increment(collection);
|
||||
let result = await qcursor.toArray();
|
||||
logger.logger.debug(result, "dbAccess.query: Response");
|
||||
logger.logger.trace(result, "dbAccess.query: Response");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user