WHAT'S NEW?
Showing posts with label no sql. Show all posts
Showing posts with label no sql. Show all posts
Today while working on MongoDb, i had a power interruption and the system has restarted. when i tried to start mongod.exe with the command
>mongod.exe --dbpath E:\MyFolder\bin
it threw me an error stating there was an issue with the close connections of Mongod. This means that data sync has some issues and so mongod cannot start smoothly
The solution for this is:
check if there is a file named mongod.lock in the bin folder. If yes, check if its size is greater than 0kB.
If yes, then delete this file, because this is the one that is intimating mongod that there was an abrupt closure of the database the previous time.
now go back to the command line and say
>mongod.exe --journal (in case journal is not set for your db)
>mongod.exe --repair
this should set the database back in line and up and running.
if you get another error like
initandlisten] exception in initAndListen: 10296 dbpath (/data/db) does not exist, terminating
then exit the cmd line and rerun the repair command and then say
>mongod.exe --dbpath E:\MyFolder\bin
to set everything back in line.
>mongod.exe --dbpath E:\MyFolder\bin
it threw me an error stating there was an issue with the close connections of Mongod. This means that data sync has some issues and so mongod cannot start smoothly
The solution for this is:
check if there is a file named mongod.lock in the bin folder. If yes, check if its size is greater than 0kB.
If yes, then delete this file, because this is the one that is intimating mongod that there was an abrupt closure of the database the previous time.
now go back to the command line and say
>mongod.exe --journal (in case journal is not set for your db)
>mongod.exe --repair
this should set the database back in line and up and running.
if you get another error like
initandlisten] exception in initAndListen: 10296 dbpath (/data/db) does not exist, terminating
then exit the cmd line and rerun the repair command and then say
>mongod.exe --dbpath E:\MyFolder\bin
to set everything back in line.
Using postman app for chrome, i was trying to post to my node js application listening to port 3001.
however, all the body of the data is sent as empty.
Because of this, the only data that is getting saved in mongodb using the mongoose connection was as below:
{
however, all the body of the data is sent as empty.
Because of this, the only data that is getting saved in mongodb using the mongoose connection was as below:
{
"_id": "542e4ea1480f9abc13239976",
"__v": 0
}
The issue with the code was that the body parser was placed at the end after the mongo connection was created and just above the app.listen(3001) line
When i changed the code to the top of the file just after the line
var app = express();
it worked for me.
now my complete code looks like this
var express = require('express');
mongoose = require('mongoose');
fs = require('fs');
var app = express();
app.configure(function () {
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.bodyParser());
});
var mongoUri = 'mongodb://localhost/MyTestDatabase';
mongoose.connect(mongoUri);
var db = mongoose.connection;
db.on('error',function(){
throw new Error('unable to connect to db');
});
require('./models/MyTestModle');
require('./routes')(app);
//moved from here to the yellow highlighted section
app.listen(3002);
console.log('Listening on port 3002...');
Over the last ten days, I was busy with a family get together. Hence, not posts and I cannot blog anything than technology and related here.
What I did in the last three days is working on a simple application that gets and sets data and perform CRUD operations on Redis: Key-Value pair NO SQL database technology.
Will upload the code in github sometime this week. see you.
What I did in the last three days is working on a simple application that gets and sets data and perform CRUD operations on Redis: Key-Value pair NO SQL database technology.
Will upload the code in github sometime this week. see you.
