Bharat's Digital Garden

MongoDB

MongoDB is a open source key value based database. It scales really well and is very flexible. I prefer using mongo in all my side projects.

Robomongo is the goto desktop client for mongo.

Scripts

Renaming fields of objects inside array’s

Ref

db.collection_name.find({ 'array_of_objects_field.0.old_name': { $exists: 1 } }).forEach(function(item)
{    
    for(i = 0; i != array_of_objects_field.length; ++i)
    {
        item.array_of_objects_field[i].new_name = item.array_of_objects_field[i].old_name;
        delete item.array_of_objects_field[i].old_name;
    }

    db.collection_name.update({_id: item._id}, item);
});