Just last weekend I was first introduced to Ionic. I’m a rank novice in mobile app development (including Javascript) so forgive my ignorance.
In my first app I am trying to store an image on AWS S3 and image metadata on MongoHQ. I’ve succeeded in the first part and am struggling in the second.
The only examples I can find for using MongoDB use are for Node.js. That starts with require(‘mongojs’). But for this first app I want to access the DB right at the client. require() seems to be a construct of Node and not Ionic. So, I guess that somewhere out there are the examples that tell me (1) how to get MongoDB access functions and data structures into my Ionic app and (2) how to use them. But I cannot find those examples.
You can’t access the Mongo DB from the client. The client has no access to the DB because it is on a remote server. You need to use Node.js and MongoDB to create an application API. Then, Ionic (or any other app using HTTP) will query the API. The server will then query the DB.
I suggest you to use http://pouchdb.com/ in case of using LOCAL database or use mongohq or others like it for remote access ( a good idea is also use CouchDB that has a RESTful interface ).
@aaronksaunders, I am using MongoHQ. But that doesn’t address my problem. I want to access MongoDB from the client. I’m currently doing this through an intermediate Node.js server. But I’m quite interested in “cutting out the middleman”, so to speak.
Firebase is amazing! But, if you are looking to scale then it’s not the best option. Look into Express and Mongoose.
A bit of shameless self promotions here…
I work at Rangle.io and we are developing a back-end framework based on express. Basically it’s just an Express app generator. And it provides a mongo mapper, so you can get your API up and running, really quick – just need to provide a schema and a config json file https://github.com/rangle/koast
Yea, there used to be a similar example using MongoLab on the angular home page before they switched to firebase. It’s great for demos and hobby projects, not really useful for production.