Reputation: 470
Everything works fine when I insert data to database. But I can't find the data inserted in robo 3T interface.....
code:
const MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost:27017/TodoApp',{ useNewUrlParser: true },(err,client) =>{
if(err) {
return console.log('Unable to connect to MongoDB server');
}
console.log('Connected MongoDB server');
const db = client.db('TodoApp');
db.collection('Todos').insertOne({
text: 'Something to do',
completed: false
},(err,result) => {
if(err){
return console.log('Unable to insert todo',err);
}
console.log(JSON.stringify(result.ops,undefined,2));
});
client.close();
});
Upvotes: 0
Views: 333
Reputation: 76
In you nodejs URL you are connecting to the ’TodoApp’ database and in your robomongo, you are connected to the ’test’ database
Upvotes: 2