Hi I am new to node and mongo DB development. I created one simple node application. I am using mongoDB. I have initialise mondo db and able to insert some data. In my app.js I added DB connection like as follow:
const mongoose = require('mongoose');
const mongoDB = 'mongodb://localhost:27017';
mongoose.connect(mongoDB);
mongoose.Promise = global.Promise;
const db = mongoose.connection;
My schema class looks like
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
let UserSchema = new Schema({
// publisherId: {type: String, required: true},
userName: {type: String, required: true},
age: {type: Number, required: true}
},{timestamps: true });
// Export the model
module.exports = mongoose.model('User', UserSchema);
now I want to access same data from command line so I tried to connect my database.
mongo mongodb://localhost:27017
It connect with this db without any error. When I try to access the data it does not show any data.I check which all databases are available. it shows default test database.