How to make a Mojito application connect to MongoDB database?


I am really new to Mojito. I am trying to see if Mojito has the ability to use anything other than YQL. I am looking to create a customized application which talks to an offline database (using MongoDB). I want to know a step by step way to have the application connect to MongoDB in the model and then query the database to get data from database. Also how would the application write data into the database?

I am looking for a detailed example how to setup such an environment? Is there a detailed step by step documentation for the same? From Mojito's documentation and code examples it seems everywhere they are using YQL and I don't have a need for that.

Any help would be really appreciated

Thanks, KA

  • k
  • Apr 16, 2013
1 Reply
  • Hey KA, mojito does not enforce the use of YQL, we use it in the examples and demos for convenience, and since it reflects the way to access data from another layer, and that's all that really matters, we think that's enough, but maybe it is not :)

    Anyway, you should be able to use Y.io or request or any other nodejs module in your model to connect to any api or database, just like we do with YQL. Models are very simple structures, they just have methods that can receive some arguments and a callback, whatever you do internally, it is just javascript. If your model has server affinity, then it is even easier because you can require any nodejs module that implements mongodb or any other type of data source.

    If you have any specific question, we can try to answer it, but at the moment we don't have any step by step example for accessing MongoDB.


Recent Posts

in Yahoo! Mojito