Relative Content

Tag Archive for javascriptnode.jsmongodb

enviroment variables file help required

I have Ubuntu OS on AWS free tier.
Ran command: npm install express mongoose dotenv bcryptjs jsonwebtoken cors
Now, in .enf file require below details:
MONGO_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret

Mongodb two collection connection with foreign key

I am using HTML, CSS, and JavaScript in the frontend, and Node.js in the backend. For the database, I am using MongoDB. Before adding the authentication page, when random users attempted the quiz, their marks were saved in the MongoDB ‘quizresults’ collection. However, after adding the authentication page, when users successfully registered, their data started saving in the MongoDB ‘user’ collection. But after login, when users submit the quiz, their marks are displayed on the screen, yet the data is not saving in the ‘quizresults’ collection in MongoDB. To resolve this problem, I have attempted to establish a connection between the two collections, ‘users’ and ‘quizresults’, but the problem still persists.