By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 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...............
  2.  
  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.     });
  9.  
  10. $scope.addContact = function(){
  11.     console.log($scope.contact)
  12.  
  13.     $http.post('/contactlist', $scope.contact);
  14. };
  15.  
  16.  
  17. };
  18.  
  19. .....................server.js................
  20.  
  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');
  26.  
  27. /*app.get('/', function(req,res){
  28.     res.send('hello world from server.js')
  29. });*/
  30.  
  31. app.use(bodyParser.json());
  32.  
  33. app.use(express.static(__dirname + '/public'));
  34.  
  35.  
  36. app.use('/contactlist',function(req,res){
  37.     console.log('server saying: i received a get request')
  38.  
  39.     db.contactlist.find(function(err,docs){
  40.         console.log(docs);
  41.         res.json(docs);
  42.     })
  43. });
  44. app.post('/contactlist', function(req, res){
  45.     console.log(req.body);
  46. })
  47.  
  48.  
  49.  
  50. app.listen(3000);
  51. console.log('server:i am running');
  52.  
plz help me
Nov 20 '15 #1
Share this Question
Share on Google+
5 Replies


zmbd
Expert Mod 5K+
P: 5,371
>OK<
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

zmbd
Expert Mod 5K+
P: 5,371
Izawad,

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

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

Post your reply

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