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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • izawad
    New Member
    • Oct 2015
    • 14

    #1

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

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

    Code:
    .................controller.js...............
    
    function AppCtrl($scope,$http){
    	console.log('hello 123456789')
    	$http.get('/contactlist').success(function(response){
    		console.log('i requested')
    		$scope.contactlist = response;
    	});
    
    $scope.addContact = function(){
    	console.log($scope.contact)
    
    	$http.post('/contactlist', $scope.contact);
    };
    
    	
    };
    
    .....................server.js................
    
    var express = require('express');
    var app = express();
    var mongojs = require('mongojs');
    var db = mongojs('contactlist', ['contactlist']);
    var bodyParser = require('body-parser');
    
    /*app.get('/', function(req,res){
    	res.send('hello world from server.js')
    });*/
    
    app.use(bodyParser.json());
    
    app.use(express.static(__dirname + '/public'));
    
    
    app.use('/contactlist',function(req,res){
    	console.log('server saying: i received a get request')
    
    	db.contactlist.find(function(err,docs){
    		console.log(docs);
    		res.json(docs);
    	})
    });
    app.post('/contactlist', function(req, res){
    	console.log(req.body);
    })
    
    
    
    app.listen(3000);
    console.log('server:i am running');
    plz help me
    Last edited by zmbd; Nov 20 '15, 07:31 PM. Reason: [z{please use the code format tool}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    >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...

    Comment

    • izawad
      New Member
      • Oct 2015
      • 14

      #3
      i am trying .

      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?

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        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 :)

        Comment

        • izawad
          New Member
          • Oct 2015
          • 14

          #5
          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.
          Last edited by zmbd; Nov 22 '15, 05:45 AM. Reason: [z{removed duplicate :-) }]

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            There appears to be a stable 32bit version for download:
            www.mongodb.org >Download MongoDB

            Comment

            Working...