login/signup function with no sessions
This commit is contained in:
6 files changed
+931
-29
No files matched your search
@@ -0,0 +1,26 @@
|
||||
const MongoClient = require("mongodb").MongoClient;
|
||||
|
||||
/**
|
||||
* connectMongo returns a database connection to MongoDB
|
||||
* @param {string} mongoURI
|
||||
* @param {string} databaseName
|
||||
*/
|
||||
const connectMongo = async (mongoURI, databaseName) => {
|
||||
const database = await MongoClient.connect(mongoURI, { connectTimeoutMS: 1000 });
|
||||
const dbo = database.db(databaseName);
|
||||
return dbo;
|
||||
}
|
||||
|
||||
/**
|
||||
* getCollection object to interact with MongoDB
|
||||
* @param {MongoClient} dbo
|
||||
* @param {string} collection
|
||||
*/
|
||||
const getCollection = async (dbo, collection) => {
|
||||
return await dbo.collection(collection);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
connectMongo: connectMongo,
|
||||
getCollection: getCollection,
|
||||
}
|
||||
Reference in new issue
Block a user