Skip to content

Commit 108c4ae

Browse files
committed
Tweaks to mongo helpers - use inferred types
1 parent 9f0b210 commit 108c4ae

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

api/src/helpers/mongo.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@module MongoHelper
33
*/
44

5-
import { MongoClient, Db, Collection } from 'mongodb';
5+
import { MongoClient, Db } from 'mongodb';
66
import { GenericObject } from '../types/types';
77

88
/**
@@ -33,7 +33,7 @@ let db: Db;
3333
* Get a mongo database object
3434
* @returns Mongo database object
3535
*/
36-
async function getDB(): Promise<Db> {
36+
async function getDB() {
3737
// if not connected yet, initiate connection
3838
if (!db) {
3939
await client.connect();
@@ -51,7 +51,7 @@ async function getDB(): Promise<Db> {
5151
* @param collectionName Name of collection to retreive
5252
* @returns Mongo collection object
5353
*/
54-
async function getCollection(collectionName: string): Promise<Collection<GenericObject>> {
54+
async function getCollection(collectionName: string) {
5555
const db = await getDB();
5656
return db.collection(collectionName);
5757
}
@@ -62,7 +62,7 @@ async function getCollection(collectionName: string): Promise<Collection<Generic
6262
* @param id ID of the document
6363
* @returns True if document ID exists in the given collection
6464
*/
65-
async function containsID(collectionName: string, id: string): Promise<boolean> {
65+
async function containsID(collectionName: string, id: string) {
6666
const collection = await getCollection(collectionName);
6767
return (await collection.countDocuments({ _id: id })) > 0;
6868
}
@@ -73,7 +73,7 @@ async function containsID(collectionName: string, id: string): Promise<boolean>
7373
* @param document Document object to add
7474
* @returns Promise that is resolved when document is added
7575
*/
76-
async function addDocument(collectionName: string, document: GenericObject): Promise<void> {
76+
async function addDocument(collectionName: string, document: GenericObject) {
7777
const collection = await getCollection(collectionName);
7878
collection.insertOne(document);
7979
}

0 commit comments

Comments
 (0)