Skip to content

Commit

Permalink
get question module
Browse files Browse the repository at this point in the history
  • Loading branch information
effy971 committed Nov 6, 2020
1 parent df29161 commit 4e19ec5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions getquestionlist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { MongoClient } = require("mongodb");

module.exports = async function (roomListArray, roomId) {
const uri = process.env.DB_CREDENTIALS;

const client = new MongoClient(uri, { useUnifiedTopology: true });
let successOrFail = false;

try {
await client.connect();

const database = client.db("4learn");
const collection = database.collection("Chatroom");

// create js obj received by /login

const result = await collection.find({ roomId: roomId });

await result.forEach((result) => roomListArray.push(result));
} finally {
await client.close();
return roomListArray;
}
};

0 comments on commit 4e19ec5

Please sign in to comment.