Archive | MongoDB RSS feed for this section

Object Modeling in Node.js with Mongoose

Check it out! We’ve just updated our Heroku Dev Center tutorial on object modeling in Node.js using Mongoose, a MongoDB ODM library. Mongoose gives your collections structure and simplifies Node’s callback patterns to make using MongoDB with Node.js even easier.

Learn more and download the sample Node.js app right here at the Heroku Dev Center.

Node.js and MongoLab on Windows Azure

(This tutorial was originally published on the Windows Azure documentation portal in January 2013)

Greetings, adventurers! Welcome to MongoDB-as-a-Service. Are you looking to create a Node.js Application on Windows Azure with MongoDB using the MongoLab Azure Store add-on?

In this tutorial you will:

  1. Provision the database – The Windows Azure Store MongoLab add-on will provide you with a MongoDB database hosted in the Windows Azure cloud and managed by MongoLab‘s cloud database platform.
  2. Create the app – It’ll be a simple Node.js app for maintaining a list of tasks.
  3. Deploy the app – By tying a few configuration hooks together, we’ll make pushing our code a breeze.
  4. Manage the database – Finally, we’ll show you MongoLab’s web-based database management portal where you can search, visualize, and modify data with ease.

At any time throughout this tutorial, feel free to kick off an email to support@mongolab.com if you have any questions. To complete this tutorial, you need a Windows Azure account that has the Windows Azure Web Sites feature enabled. You can create a free trial account and enable preview features in just a couple of minutes. For details, see the Create a Windows Azure account and enable preview features tutorial.

In addition, ensure that you have the following installed:
Continue Reading →

Experiment with MongoDB 2.4 on MongoLab!

Hello to all our friends and users!

We’re happy to announce that free, experimental databases running MongoDB 2.4 are now available at MongoLab! To get started quickly, follow our step-by-step guide.

Please note: This release is not ready for production yet and should not be used for any production applications.

Release Highlights

Here are the exciting new features and improvements in MongoDB 2.4 that we’d like to highlight:

Full-text search

For your exploration, we are boldly ignoring the warning label on this feature, which is described as an “experimental feature” in 2.4, and are running these servers with textSearchEnabled=true.

You get one text index per collection and create it, similarly to spatial indexes, by providing a special value in your index creation call.

The following simple example text-indexes the “skills” field of the “players” collection.

> db.players.ensureIndex({"skills": "text"})

You can include more than one text-indexed field in a single text index as well as other fields, such as:

> db.players.ensureIndex({"skills": "text", "interests": "text", "age": 1})

To run a query that returns documents that contain the word “telepathy” (case-insensitive) in either the skills or interests fields:

> db.players.runCommand("text", {"search": "telepathy"})

There are several considerations when making a text index and even useful options such as weighting of fields. So… before you make use of this feature, be sure to read the text indexes documentation.

The above example uses the mongo shell. If you want to run through this example in MongoLab’s admin UI, scroll on down…

JavaScript engine now uses v8 as the default

The default JavaScript interpreter used throughout MongoDB, for the mongo shell, mapreduce, $where and eval is now v8 instead of SpiderMonkey. For all users making use of the JavaScript engine, we encourage you to run the same code against this new engine and see how it performs!

Better GeoSpatial indexing

Spherical Geospatial queries are now supported by their own index type. You can create this new type of index just like you currently create a geospatial index, except that you need to specify “2dsphere” in the index definition instead of “2d”. Much like the 2d index requirement of storing [long, lat] data in a certain format, 2dsphere indexes have specific data considerations; for example, you must store a point, line, or polygon in GeoJSON format.

This new index type becomes even more useful with the $geoIntersects operator. Now, MongoDB can tell you if two of your shapes overlap. This is a powerful but specialized tool, so familiarize yourself with the details by reading the release notes and make sure it’s right for you.

An interrupted index build can now be resumed

Ah – this feature improvement is music to our ops-centric ears!  Previously if your mongod process died (either through intentional shutdown or unexpected termination) while you were building an index, you had to start the index build from scratch again.  As of this release, mongod will continue where it left off on an index build after the process starts again.

Example: A simple full-text search using MongoLab

Below is a step-by-step guide to creating a free database running MongoDB 2.4 and running your first full-text search.

[1] Sign up for a MongoLab account if you don’t already have one

[2] Click the “Create new” button after you are logged in to create the database, checking the highlighted checkbox below.  Note that database names need to be unique within an account and mongod process.
Screen Shot 2013-02-07 at 12.44.48 PM

[3] On the “Collections” tab click “Add” and create a collection called “players”

[4] We need some data to run a search against, so click into the row representing this collection so that we can add some.

[5] Click “Add” and copy the following document into the JSON editor:

     { "skills": "telepathy archery",
       "interests": "eating drinking",
       "age": 34 }

[6] On the “Indexes” tab click “Add” to text-index the “skills” and “interests” fields

Screen Shot 2013-02-08 at 12.42.25 PM

[7] Let’s run our first full-text search! On the “Tools” tab and the “commands” sub-tab, select the “text” command:

Screen Shot 2013-02-08 at 12.37.08 PM

Questions or Thoughts?

As you play around with our experimental databases running this new release, please email us anytime! We are eager to help you as you explore this exciting release or if you have any other questions or thoughts about MongoDB.

{ "comments": 3 }

DZone MongoDB Reference Card

As developers we’re always appreciative of documentation that lets us absorb a lot of detailed information as quickly as possible. While nothing can replace a detailed reading of the core MongoDB documentation from 10gen, a few pages of pithy reminders can make operational life a lot easier.

MongoLab sponsored the recent DZone reference card for MongoDB. Here’s a little snippet below. Download the rest of it here http://refcardz.dzone.com/refcardz/mongodb(registration with DZone required)

Dzone Refcard screenshot-02

Thanks to Kristina Chodorow and the 10gen crew for a nice reference card and to the folks at DZone for producing it!

UPDATE 2013-02-06: added note saying that DZone requires registration

Automated Slow Query Analysis: Dex recorded presentation from MongoSV 2012

Automated Slow Query Analysis: Dex the Index Robot

On December 4th, MongoLab engineer Eric Sedor presented about “Automated Slow Query Analysis: Dex the Index Robot” at MongoSV 2012, an annual one-day conference in Silicon Valley, CA, dedicated to the open source, non-relational database MongoDB.

A well-indexed query improves performance by several orders of magnitude. The trick is to identify an ideal set of indexes for a particular use case. Even for experts, hand-crawling MongoDB log for slow queries is a laborious process. Introducing Dex: an open-source automated tool for analyzing the slow query log or system.profile collection. Dex’s primary author Eric Sedor demonstrates Dex’s usage and elaborates on indexing topics from the basic to the advanced. Includes how to pick indexes in an elegant, practical way. You learn how Dex categorizes slow queries and recommends indexes to help keep your application running smoothly. Eric is an engineer at MongoLab, cloud-hoster of MongoDB, where Dex is used daily to optimize customer indexes.

Check out the recording below and please be sure to check out 10gen’s page for the presentation which has links to Speaker Deck slides and an alternate video link.

Here’s Dex’s github page, and the latest version (0.5) announcement

MongoLab Discount for JS.everywhere() 2012

MongoLab is happy to be sponsoring the JS.everywhere() conference in Silicon Valley at the end of October. If you’re interested in joining us, please use this discount code on the registration page: “mongolabJS”.  You’ll get 50% discount on attendance. We are looking forward to seeing you there.

MongoDB’s native support for JSON of course makes it a natural fit to work with Javascript.  Javascript’s growing popularity beyond browser clients is driving the need for a scalable JSON persistence layer.  Having that cloud persistence layer at MongoLab, we get to see many interesting new projects in enterprises large and small.  So we’re excited to be reaching out to meet new users.

Details on our events page:

URL: http://www.jseverywhere.org/
Registration URL: http://jse2012.eventbrite.com/
Discount Code: mongolabJS
Dates: October 26-27, 2012
Location: San Jose, CA

Nodestack


We’re excited be part of the Oct 17 Nodestack.org online conference with Joyent, Clock Ltd, 10gen, and Nodejitsu.

What is Nodestack?

If you’re a Web developer you may have felt the same thing in the last year or so: Javascript is winning. More precisely, Joyent’s Node.js, supported by 10gen’s JSON-centric MongoDB database for persistence is winning. And by using SmartOS as the host for Node.js, Joyent offers the inspectability, performance, and debuggability capabilities of DTrace and ZFS to Nodestack.

Parochially, I’ve included a Google Trends widget above comparing “node”, “ruby”, and “java” when searched with “mongodb”. As of this writing, “node” had just crossed “ruby”s trend line and was headed up to challenge “java”.

Why Nodestack?

There are many reasons why Nodestack is emerging as a leading developer choice, including:

  • developer familiarity with Javascript from front-end browser domains
  • the battle-tested underlying Google V8 Javascript engine for high performance
  • a harmonious non-blocking asynchronous IO environment resulting in efficient CPU utilization
  • good fitness for demanding near real-time dynamic web and mobile applications
  • effortless JSON-awareness across the stack means fewer developer cycles wasted on data translation
  • a well-supported package management system with growing library of components for basic and advanced needs
  • a deep-bench ecosystem of infrastructure, platform and consulting services from vendors like Joyent Cloud, Nodejitsu and Clock Ltd. for even easier design, development, and production.
  • mdb_v8, DTrace and flame graphs (visual temporal call graphs) on SmartOS for fast root-cause analysis / debugging.

Nodestack Conference

At the Oct 17 online conference, you’ll talk with:

  • Nodejitsu’s Nuno Job on “Crazy, Cool Things You can do with Node.js”
  • 10gen’s Aaron Heckmann on “Node.js + MongoDB = Love” and why these technologies fit so well together.
  • Joyent’s Bryan Cantrill on “Stack Foundation = SmartOS” on SmartOS’ hypervisor benefits for Nodestack including flexibility for KVM virtualization
  • A panel including 10gen’s Jared Rosoff, Joyent’s Jason Hoffman, Clock Ltd’s Paul Serby and yours truly on the economic benefits of Nodestack.

So please sign up here to join us. The webcast is scheduled to start at 9am PT on Oct 17, 2012.

*If you are local in San Francisco, CA, we’re also inviting a few folks to join us as part of the studio audience. Email ben at mongolab dot com if you’re interested. See our Events page for other events.

Updated: 2012-09-28 with exact start time. Grammar fix ^less^fewer. Added link to Aaron’s preview post; mdb_v8, David Pacheo deck.

2012-10-01 fixed broken SmartOS link.

MongoSeattle 2012 with talk on Dex

(update: slide deck here https://speakerdeck.com/u/ericsedor/p/dex-the-index-bot)

We’re attending and sponsoring MongoSeattle 2012 on September 14!  Eric Sedor will be presenting his recent work on Automated Slow Query Analysis: Dex the Index Robot our open source tool at 11:30am in the “Sound” hall.  Source code and instructions available here on github.

We’ll have our booth to talk to folks about our MongoDB offering in the cloud and with PaaS providers.

Location: Bell Harbor International Conference Centerq 2211 Alaskan Way, Pier 66, Seattle, WA 98121 206.441.6666

Registration: here.

We have a few community discount passes left.  Email ben at mongolab.com if you’re interested.