By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,866 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,866 IT Pros & Developers. It's quick & easy.

my mongo database not connect with my node server.................

P: 14
hi help me,
my mongo database not connect with my node server. here my code.

Expand|Select|Wrap|Line Numbers
  1. .................controller.js...............
  3. function AppCtrl($scope,$http){
  4.     console.log('hello 123456789')
  5.     $http.get('/contactlist').success(function(response){
  6.         console.log('i requested')
  7.         $scope.contactlist = response;
  8.     });
  10. $scope.addContact = function(){
  11.     console.log($
  13.     $'/contactlist', $;
  14. };
  17. };
  19. .....................server.js................
  21. var express = require('express');
  22. var app = express();
  23. var mongojs = require('mongojs');
  24. var db = mongojs('contactlist', ['contactlist']);
  25. var bodyParser = require('body-parser');
  27. /*app.get('/', function(req,res){
  28.     res.send('hello world from server.js')
  29. });*/
  31. app.use(bodyParser.json());
  33. app.use(express.static(__dirname + '/public'));
  36. app.use('/contactlist',function(req,res){
  37.     console.log('server saying: i received a get request')
  39.     db.contactlist.find(function(err,docs){
  40.         console.log(docs);
  41.         res.json(docs);
  42.     })
  43. });
  44.'/contactlist', function(req, res){
  45.     console.log(req.body);
  46. })
  50. app.listen(3000);
  51. console.log('server:i am running');
plz help me
Nov 20 '15 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 5K+
P: 5,397
1) More detail such as any errors (detailed) and what it is doing versus what you expected.

2) You need to do the basic trouble shooting first. Using your debugger, step thru the code. Make sure that all of your strings are resolving correctly, etc...
Nov 20 '15 #2

P: 14
i am trying many time but no one error is showing. i am to confuse where my mistake?
how can get and post data in mongodb?
my problem is
when i post my data server does not get my post. and error is not shown into console. what can i do?
Nov 21 '15 #3

Expert Mod 5K+
P: 5,397

With a caveat emptor in place - namely, that I don't have much knowledge of MongoDB and JAVA appilications :) -
I don't see where the actual connection is made to the database...

Do you have the instance started for the database?

I don't know how exactly you are implementing the MongoDB, there appears to be a few methods to do this; thus, here's the tutorial homepage for MongoDB/JAVA via MongoDB site: Getting Started with MongoDB (Java Edition)

+ This is another site I use for tutorials, this is the root page so that you can double check one method of installation.
MongoDB - Java

++ I wish that could be of more assistance to you in this matter; however, as afore mentioned, I have no experience with MongoDB and JAVA. Hopefully one of our experts more versed in this will be able to provide some better guidance :)
Nov 21 '15 #4

P: 14
thanks dude
i am trying and searching where my problem? thanks for guidance may be i have window 32 bit therefore mongodb is create problem.
Nov 22 '15 #5

Expert Mod 5K+
P: 5,397
There appears to be a stable 32bit version for download:>Download MongoDB
Nov 22 '15 #6

Post your reply

Sign in to post your reply or Sign up for a free account.