MongoDB atlas connection working but not showing in Collection

I want to display the users from my database in MongoDB Atlas. I have successfully created a connection but am not able to show the users in collection

Hello @Shubham_Kumar5, Welcome to MongoDB Community Forum,

It would be very helpful if you show your implementation and problem that you are facing, otherwise, no one can understand your problem.

Hi Vishal!
Actually, I have successfully connected MongoDB atlas, and the connection is working fine.
I have created a schema but the thing is it is not getting displayed in the collection (MongoDB atlas).
The connection is working fine but I am not getting any response from the database.

I have given 0.0.0.0/0 as an IP address in MongoDB Atlas so that anyone can excess it.

This is how my schema looks like

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const UserSchema = new Schema({
    firstName: { type: String, required: true, trim: true },
    lastName: { type: String, required: true, trim: true },
    username: { type: String, required: true, trim: true, unique: true },
    email: { type: String, required: true, trim: true, unique: true },
    password: { type: String, required: true },
    profilePic: { type: String, default: "/images/profilePic.png" },
});

var User = mongoose.model('User', UserSchema);
module.exports = User;

But I am not getting anything in my mongodb atlas collection.

You have designed the schema, it will not create collection in database,

You have to insert document using insert query, for more details you can follow the mongoose documentation.

https://mongoosejs.com/docs/models.html

2 Likes