Compile djondb on Mac OSX

This is a step by step process about “Compiling djondb on Mac”, this will cover all the steps, if you already have installed one of the tools (for example home brew) then you can skip the step and move to the next one.

If you have any trouble, please let us know in the comment section, this will be updated with any new release or change to the process.


The first step is to install the xcode and the xcode command line tools, this will allow you to compile, debug, etc. It’s a prerequisite for home brew and djondb. XCode and XCode command line tools can be downloaded from apple’s developer page.

The next step will install home brew, if you already have brew installed in your system please do: “brew doctor” to check that everything is ok.

Home brew

Some of the tools required by compilation scrips will be installed using Home brew, this is a very good installation manager for OSX. The full installation instructions are in the home brew page, basically it will lead you to execute:

ruby -e "$(curl -fsSL"

Once it’s installed please execute the command: brew doctor, which will check for anything that could be wrong on brew and fix the suggestions made by it.


Now with brew installed you could install some tools that will be used later:

brew install cmake
brew install git
brew install boost

Download the code

djondb source code is available at github, to download it just execute:

git clone
cd djondb
git checkout devel

This compilation process is available at the current development branch, later this will be transferred to the master branch.

Make dependencies

This step will take around 15 minutes, it will compile the djondb dependencies. These dependencies will be sit at third_party/libs and third_party/includes folders.

cd <djondb dir>/db
make dependencies

Building djondb

The final step will build djondb.

cd <djondb dir>/db
mkdir build
cd build
cmake ..
sudo make install

Ready, one final step and everything will be set.

Make data dir

the data folder is where djondb files will be created, so you will need to create it.

cd <djondb dir>/db/third_party
sudo sh

Done, you are ready to test, run or change the code of djondb.

Creating a ToDo list with djondb, ASP.Net Web API and Knockout JS


In this post, we are going to create a sample ToDo list application using djondb, the enterprise class NoSQL database. The purpose of this article is to show how to use djondb in a Windows environment with .NET framework.

Setting up

First of all, install djondb, here is a video that shows how to do it:

Then, install install djondb’s C# driver for Windows. There is also a video for this:

Now we are running djondb in a Windows environment. Pretty simple.

Designing the application

We want to build a ToDo list. We want to:

  1. Add a task
  2. Retrieve all tasks
  3. Remove a task
  4. Complete a task from the ToDo list

We’ll create a web client using Twitter bootstrap and Knockout.js. We’ll create a REST services layer using ASP.Net Web API with .Net Framework 4.5. And, obvious, we’ll use djondb to store the tasks of the ToDo list.

The image below depicts the architecture of the application:

Continue reading

New drivers and new youtube channel

Today we released the C# driver and a new youtube channel where we will put videos showing how to use djondb and we will use it to explain NoSQL concepts that could take forever to put in a blog.

Enjoy it. Here’s the first video: <a href=" cialis aus” onclick=”__gaTracker(‘send’, ‘event’, ‘outbound-article’, ‘’, ‘djondb – C# driver’);” target=”_blank”>djondb – C# driver

The Youtube channel is: djondb Youtube channel

djondb is open source

djondb has been created as an open source project since beginning, but was not until now that I opened the code to the public, why? because I think the project is getting to an stable point both in features and bugs, so this is a good moment to share the code and start growing it up with the help of the community.

One of the keystones of djondb is to provide enterprises with a highly consistent database, but ensuring you can build up applications in no time, at this point this is possible and you can create applications in 10 minutes, later I will post examples of how to build applications that uses NoSQL to power up the data management and leverage the effort required to create an application from scratch.

Want to contribute?

There’re several ways to contribute to this project: The obvious one will be to get the code, create new features and help the project to grow up, but there’re other ways to help:

  • Download the database and install it on your own environment, didnt work? great send a request using the support group or post an idea/request using “feedback” (you could find it at the right in djondb cialis rezeptfrei
  • Test the database and submit any bug you get.
  • Improve the documentation creating real life samples that I will copy’n paste in djondb documentation (I will put your name on it)
  • Post a blog about djondb encouraging your friends to use it and spread the word.
  • Need a driver?, post a request on the feedback tool or google support group and we will work on it.
  • Fork the code, hack it and do a pull request using github


djondb uses both a GPL and commercial license, if you have an special condition that requires a different license just contact us at

New “Select” feature

A new version of djondb is available!

Find with select

With the version 0 potenzmittel 100 pillen cialis tadalafil.120120913 of djondb you will be able to retrieve partial contents of your stored BSONs, this will reduce the bandwidth consumption, memory, etc.

It’s very easy to use, let’s see how it works using a product namespace, here’s a sample of one document stored:

    "code": "0001",
    "prod_name": "TV",
    "price": 550,
    "retail": [
            "name": "Photo Plus",
            "address": "Av Rockdrive 1345"
            "name": "TV Club",
            "address": "Av Sunshine 4512"

If you want to retrieve a list of your products, but you dont want to retrieve all the information of the product, then you will use:

find(‘mydb’, ‘products’, ‘$”prod_name”‘, ”);

this will retrieve all your products, including only the product name as part of the result, here’s the result of the above instruction:

    { "prod_name": "TV" },
    { "prod_name": "Camera" },
    { "prod_name": "DVD" }

What if you want to retrieve the product names and the name of the retailer?, then you will use:

find(‘mydb’, ‘products’, ‘$”prod_name”, $””‘, ”);

this will get the following result:

        "prod_name": "TV",
        "retail": [
            { "name": "Photo Plus" },
            { "name": "TV Club" }
        "prod_name": "Camera",
        "retail": [
            { "name": "Photo Plus" },
        "prod_name": "DVD",
        "retail": [
            { "name": "TV Club" }

it couldn’t be easier, What do you think?

NoSQL: Master/Detail sample

Recently I gave a speech about the NoSQL subject and one of the main concerns was: “How can I manage my relationships if NoSQL is not relational?”, also I found that this is a very common question and one of the key scary parts when you’re approaching to the NoSQL Document world. (take a look at stackoverflow and you will see what I’m talking about)

To address this I will explain how to model a “typical” enterprise application using documents and how to approach the design of your model using djondb.

The problem:

I want to create a receipt system using NoSQL: In other words you want a system to your restaurant that will handle all the purchases made saving the receipts (taxes issues comes to my mind), but you want to be able to get some “reports” or any kind of tracking system to know how much you sold, what is the favorite food, etc.

The RDBMS approach

I know every architect could get a different solution for this problem, but I will go to the “easier” to understand approach, a master/detail tables with a form screen that will capture the receipt and save it to these master/detail tables. Does it sound familiar?

First step model the database:

This two tables will hold our receipts, to get a workable sample you will need the Customer and Products tables, so let’s add them:
<a href=" cialis preis.png”>

Now that you’ve your data model is time to build up your application, the implementation will be heavily influenced by the development language, but this will look like this:

Until now, the life was good with us, everything looks clean and easy, the DB is created the screen looks nice, etc. But how will this work on the server side? Lets assume the following workflow:

  • The user enters to the screen, the date is automatically filled.
  • He needs to select the customer, so we create a new screen that pop ups up and do some lookup to select the customer
  • Now that the user wants to add items we have two choices (since we’re on web the decisions are different from a desktop application):
    • First: Save the “master” record and then start to add items to it
    • Second: Add the items into memory (browser or session variables) and store everything at “checkout” button

    No matter which one is your choice, or any other choice, your code will do the following instructions:

    • Insert into Master Values (‘2012/10/10’, 7172772) (let’s assume the client id is: 7172772)
    • Insert into Detail Values (10, 10012, 1, 350) (iPhone code is 10012)
    • Insert into Detail Values (10, 10015, 2, 3) (Cable code is 10015)

    If you’re using jQuery or any other UI framework the chances are high that you’re using json as interchange format, if not you will just get each value, one by one and format it to fill some parameters into the SQL statement.

  • Ufff… almost done, now you will need to show the receipt to the user (readonly mode), at this moment you’re confident with your SQL statements and you create the following:

    SELECT … From MasterDetail md inner join Products p on = md.prodid where idCustomer = 7172772

    This will retrieve the details element, but you will need another select to retrieve the header of the receipt, so you go and write on some code:

    SELECT … FROM Master m inner join Customer c on = m.customerid where = 7172772

    Then you use your backend code to format this into some jsons and return it to be rendered by the framework at the browser side.

Ok, this was the process to create and model a typical RDBMS solution, you could argue that you can use ORM (EJB, Hibernate, etc) or something like this, but at the end you will just need more classes, more code and more “pain”.

The solutions looks awesome, it’s easy and straightforward, but 2 months later you realize that there’s a new model of iPhone and the one you create could be misleading because the name does not states that is the iPhone 3 and not the iPhone 4S, you need to “update” the old product record to change the name of the product, this is a trivial task, just create an update sql and that’s it, right? BUT… what if a customer comes later and want to reprint his receipt? you cannot change the product name, the receipt should be exactly as it was on the time of the sell, right? (denormalization comes to save the day, and you will need to change some SQL instructions, some code at server side, the screen, darn, you will need to change everything)

NoSQL solution

The same problem from the NoSQL side, it’ll be something like this:

  • Although you don’t need to create the tables, databases, etc in order to use them, it’s wise to model your data in advance, this will avoid some typical mistakes. The browser will send the following json as soon as the user press the “check” button:
    "date": "2012/10/10",
    "Customer": { "id": 7172772, "name": "John Smith"},
    "details": [
    {"productId": 10012, 
    "description": "iPhone", 
    "units": 1, 
    "price": 350},
    {"productId": 10015, 
    "description": "USB Cable", 
    "units": 2, 
    "price": 3}

    Take a look how I started denormalizing the data from the beginning, this will avoid extra queries and will solve the “drawback” problem stated before.

  • At the server side you will just store the document into djondb using something like:
    $c = new Connection();
    $data = $_POST['data'];
    $receipt = json_encode($data);
    $c->insert('testdb', 'receipt', $receipt);

    I didn’t need to breakup the incoming parameters or create any SQL statement, just send the record to the database, take a closer look I’m saving the product’s name and customer’s name, this will avoid the problem mentioned at “drawbacks” from the RDBMS solution (you could change the RDBMS too, but this will just add more and more text to this already long post). If you want to do some checks at the server side you could use the JSON as is, and just do the validations on the serverside (most of the languages already has some JSON framework).

  • Now, how do you retrieve the data from the server and draw it as readonly. Easy… first the server side code:
    $c = new Connection();
    $id = $_GET['customerid'];
    $filter = '{ customerid: "'.$id.'"}';
    $jsonResult = $c->findByFilter('testdb', 'receipt', $filter);

    Here you will get the document from djondb and sent it as is to the user interface and render the data using jquery is a trivial task, you will not need to retrieve each part of the receipt (master/detail) separated just one sentence and that’s it.

One of the beautiful things of jQuery is that you can manage the screen on memory and send the full json to the server once the user press the “check” button, you can add records and do some ajax to return the products name, customers, etc and keep the master/detail model into a json variable at the browser side and send a single process request to the server to save the full receipt, using NoSQL you could store this straighforward to the DB, but at the RDBMS you will have some problems to split the information before you can store it to the database, even if you use a ORM mapping framework you will end up with more code that in the NoSQL world.

Updating the product’s name

As I said before what if the product’s name changes and I want to keep the receipts as they are at the moment of the creation, using the denormalized approach this will not have any problem, just do a update on the products table (RDBMS model) or at the document in djondb.

Adding new fields to the model

The next typical problem is related with the new fields, how will I handle this will be my next post, so keep up.