Showing posts with label nodejs. Show all posts
Showing posts with label nodejs. Show all posts

Wednesday, April 6, 2016

trying to open unclosed connection

When having the error, the first thing to do is to restarting your mongo database.
If the error still persist, chances are that your connection statement is as below:

var dbUrl= 'mongodb://localhost:27017/test';
mongoose.connect(dbUrl);

To solve it , change connect to createConnection

var dbUrl= 'mongodb://localhost:27017/test';
mongoose.createConnection(dbUrl);


It should be working now, if not drop me a comment and will come to your rescue...


Monday, March 14, 2016

TypeError: require(...).connect is not a function

I recently had  a hard time trying to fix this issue.
I initially wrote these lines below to establish my connection:

var databaseUrl = "localhost/school";
var collections = ["student", "professor"]
var db = require("mongojs").connect(databaseUrl, collections);
var http = require("http");


Now it seems that since 1.x , mongojs no longer support the connect function,
instead we should replace the third line with:


var db = require("mongojs")(databaseUrl, collections);


Source: https://github.com/mafintosh/mongojs/issues/286


 

the default storage engine 'wiredtiger' is not available issue solved

I have created my data/db in the bin folder, for more about the installation watch this tutorial

Now to start mongod, instead of :

mongod --dbpath ./data/db

Do this instead:

mongod --storageEngine=mmapv1 --dbpath ./data/db

Hope it helps:



mongodb unclean shutdown detected

Are you having this error message : mongodb unclean shutdown detected ?
In my system I have my data/db under the bin folder
if you are using linux :

sudo rm /data/db/mongod.lock
sudo mongod --dbpath /data/db --repair
sudo mongod --storageEngine=mmapv1 --dbpath ./data/db
 
 
if you are using windows:
 
Go to your data/db directory:
1. delelte mongod.lock file
2. mongod --dbpath ./data/db --repair
3. mongod --storageEngine=mmapv1 --dbpath ./data/db 
 
More about the issue here