Tag Archives: BSON

NODEJS TUTORIAL: USING MONGODB


via Node.js Tutorial: Using MongoDB.

In this tutorial you learn how to use MongoDB with Node.js. MongoDB is an increasingly popular document-based, high-performance NoSQL database. In MongoDB, data is stored as a document as a set of key-value pairs. You can define multiple databases in MongoDB where each database can have many collections, and those collections are simply a set of documents that consist of data stored as a key-value pair.

The data structure that defines a MongoDB document is called BSON (Binary JSON). BSON is binary representation of JSON and also supports data types such as Date, which is not supported in plain JSON format. MongoDB internally converts JSON to BSON and vice versa for performance benefits, although the user can save, query and retrieve as JSON.

Managing files with NodeJS and MongoDB GridFS


via Managing files with Node.js and MongoDB GridFS.

The technology stack was pretty simple, Nginx serving us on the front of the battle field and passing some of the requests to the node.js web server. For data storage we went with MongoDB, we hopped on the NoSQL wagon and just rolled with it. And as in many other projects we needed some sort of file management. Did some research and had to give a try to gridfs. So we used gridfs to manage and serve images (and in the future also other files too).

GridFS is a specification for storing and retrieving files that exceed the BSON-document size limit of 16MB. Instead of storing a file in a single document, GridFS divides a file into parts, or chunks, and stores each of those chunks as a separate document.

Probably now you ask yourself, can I store files smaller than 16MB? the answer is YES. You can store any size of files, all the files are going to be chopped up in chunks. Should I use gridfs if my files are under 16MB? It depends on your use case, I would suggest you do to some tests and research before using it, maybe it’s enough to use the simple BSON model.

So for using gridfs the advantages are numerous, for example you can take advantage of load balancing and data replication features over multiple machines for storing files. Also your files are splitted in small chunks. So for example getting a portion of your video file should be fairly easy to do.

GridFS by default uses two collections: fs.files and fs.chunks to store the file’s metadata and the chunks. Each entry in the chunks collection represents a small piece from a file. A document from the chunks collection contains the following fields:

General ruby templating with json, bson, xml, plist and msgpack support


Click to Read

RABL (Ruby API Builder Language) is a Rails and Padrino ruby templating system for generating JSON, XML, MessagePack, PList and BSON. When using the ActiveRecord ‘to_json’ method, I find myself wanting a more expressive and powerful solution for generating APIs. This is especially true when the JSON representation is complex or doesn’t match the exact schema defined within the database.

Whitepaper: RDBMS TO MONGODB MIGRATION GUIDE: CONSIDERATIONS AND BEST PRACTICES


RDBMS TO MONGODB MIGRATION GUIDE: CONSIDERATIONS AND BEST PRACTICES

Companies ranging from startups to Fortune 500s choose NoSQL to build, improve, and innovate:

The relational database has been the foundation of enterprise data management for over thirty years. But the way we build and run applications today, coupled with growth in data sources and user loads, are pushing relational databases beyond their limits. To address these challenges, companies like Salesforce.com, MTV and Cisco have migrated successfully from relational databases to MongoDB.

This whitepaper provides a step-by-step guide for project teams that want to know how to migrate from an RDBMS to MongoDB. It also explains the considerations for teams that come from relational database backgrounds and want to build new applications on MongoDB.

Download this whitepaper to learn:

  • Schema design, moving from relational tables to flexible and dynamic BSON documents
  • Data integrity, and how MongoDB ensures atomicity, data durability and strong consistency
  • Query model & data analysis in MongoDB
  • Data Migration, including scripts and parallel operations
  • Operational Considerations, like scaling, HA, monitoring, security and backup

Javascript + C++ BSON parser


Javascript + C++ BSON parser

This BSON parser is primarily meant to be used with the mongodb node.js driver. However, wonderful tools such as onejs can package up a BSON parser that will work in the browser. The current build is located in the browser_build/bson.js file.

A simple example of how to use BSON in the browser: