2

I would like to use MongoDB directly at client side of an Mac OSX app, i.e. I want to store my models in a mongoDB. Is this possible? Most of the documents I saw explained how to access mongoDB that is present in a server.

Kiran Balegar
  • 916
  • 6
  • 16
  • The thing's written in C++, so it should be "possible" – CodaFi Jun 21 '13 at 04:16
  • why not coredata or sqlite ? why mongodb ? – Srikar Appalaraju Jun 21 '13 at 04:30
  • Why use mongodb on client side. It really doesn't make sense. Mongodb is meant for scaling horizontally and that is achieved by having low range of queries compared to SQL. For client side use SQLite. Mongo is meant for scaling and I pretty sure you must be having less data which you wish to store, else you would have gone for server side db hosting. – Sushant Gupta Jun 21 '13 at 05:04
  • 1
    @Kiran also read this http://stackoverflow.com/questions/1476295/when-to-use-mongodb-or-other-document-oriented-database-systems – Sushant Gupta Jun 21 '13 at 05:10
  • @all Lets say I dont have option to use any other DB other than mongoDB. – Kiran Balegar Jun 21 '13 at 05:56
  • @SushantGupta I have a pretty big data and its the reason I even started to look towards mongoDB. – Kiran Balegar Jun 21 '13 at 05:57
  • 1
    Take a look at ObjCMongoDB. ObjCMongoDB is a Mac OS and iOS library for MongoDB and BSON based on the 10gen C driver. – Parag Bafna Jun 21 '13 at 11:49
  • 1
    MongoDB is very convenient to use even for a very small data set. I agree with the suggestions here to install MongoDB on the client, run it as a separate process, and connect to it from your app. – A. Jesse Jiryu Davis Jun 21 '13 at 17:09

2 Answers2

2

There are undoubtedly a lot of other options for databases, even Mongo-like databases, but if you want to use Mongo on the client, by far the simplest way is to run Mongo as a separate process on your client machine. Using Homebrew or the 10gen Mac installer you can have it running in a few minutes. By default the server doesn't require authentication, so there's almost nothing to configure.

I wrote ObjCMongoDB. Using that it's simple to interact with the local instance.

A local instance plus a driver is the same way you'd build an application if you were required to use say PostgreSQL or MySQL – though again, there are other options for databases. It's perhaps a little easier with Mongo since collections just pop into existence when you start using them.

There's not an easy way to embed Mongo into a Cocoa app.

paulmelnikow
  • 16,895
  • 8
  • 63
  • 114
1

If you want something like MongoDB running on the client side, I'ld recommend you to use ejdb instead. It's specifically built for that purpose.

It aims to be a fast MongoDB-like library which can be embedded into C/C++/NodeJS/Python/Lua/Java/Ruby applications under terms of LGPL license.

cutsoy
  • 10,127
  • 4
  • 40
  • 57