1

I come from a LAMP stack background but lately I am been interested in Node.js/Angluarjs combo. Now I am wanting to get Mongodb into the mix but I am having the hardest time getting it set up. Every tutorial I find using a different kind of stack, some are using Express.js, others Mongoose, or something else. How do I go about using angularjs HTTP service to connect to Mongo? Do I need an intermediate library like Mongoose or can I do it directly with Angular. I had set this up a while back as an experiment. I am trying to do what I am doing in this page. In this, I am storing the data in a JSON file. I want to replace that JSON file with a connection to the Mongodb. I have MongoDb installed globally for Node and I have created a data collection through the console. You can see my experiment here - http://monkbunker.com/saas/#/ And the code for the http connection I have for this can be seen here starting on line 14 https://github.com/seanandersonmke/saas/blob/master/js/main.js

Is this similar to how I can work with MongoDB? How to set up an initial connection? I have sat down several times now for hours and ended up stumped every time. Please help. thanks.

Sean Anderson
  • 241
  • 3
  • 17

1 Answers1

1

Have a look on the following links:

Querying MongoDB with JSON / HTTP / REST Interface

Does MongoDB have a native REST interface?

There is a full python proxy solution: http://python-eve.org/

Maybe this is helpful for you.:)

Community
  • 1
  • 1
apinnecke
  • 51
  • 1
  • 3
  • Every time I follow documentation, I get some kind of error. For example, the official express docs have this - var express = require('express'); var app = express(); app.get('/', function(req, res){ res.send('hello world'); }); app.listen(3000); but right away I get an error "required is undefined"...that is just one example. – Sean Anderson Jan 18 '15 at 19:16
  • Also, I have been using Yeoman, trying to get basically a boilerplate app installed with all the dependencies but I ALWAYS get some sort of errors. Does, anyone have a simple code example for a very basic Mongodb connection...THAT WORKS? – Sean Anderson Jan 18 '15 at 19:19
  • One more thing...if you look at my code sample I posted, if can't take a whole lot of code to change that connection to mongodb instead of a JSON file. What could I add to that page to make it work? – Sean Anderson Jan 18 '15 at 19:22
  • @SeanAnderson How do you run your express code? is express installed? – apinnecke Jan 18 '15 at 19:35
  • I have done numerous tutorials and keep getting errors. I was trying to set this up - http://meanjs.org/docs.html, I get stuck really early at NPM install, I get GIT not installed errors (though I have it installed, apparently it is not set in my Windows System Path. I like the idea of this YO package manager but I get errors constantly. What if I skip the Yeoman manager and install packages myself in Node.js command line, Empty folder, install angularjs, install express.js, install mongodb, run NPM init, then NPM install. That should give me everything I need in place right? – Sean Anderson Jan 18 '15 at 20:55
  • Uhh, I'm out with windows. That seems to be a problem with your generic npm and git setup, which i can't help you with. I assumed you were searching for an abstraction layer and were stuck in docs implementing one on your own. :( – apinnecke Jan 19 '15 at 21:15
  • 1
    A lot of the errors I was having was solved by adding git to my Windows system path, which it apparently does not do automatically when installing in Node.js. Once I figure out how to get a connection to mongodb with angularjs, I will post my code. – Sean Anderson Jan 19 '15 at 23:05