Using MongoLab with Exadel’s Tiggzi cloud-based mobile application builder

  A terrific Cloud-based mobile app builder is Tiggzi from Exadel .  Max Katz who heads developer relations will be at the AT&T Education Hackathon this weekend in Palo Alto.  MongoLab will be there as well, and I thought that it would be nice to have a demo to show how to get data from a cloud-hosted MongoLab instance into a Tiggzi mobile application.  That means you can very quickly build an iOS or Android app, or a Web app, all backed by the leading standard for document storage, MongoDB.  For more info about the MongoLab REST API, see this documentation page.

MongoLab includes a REST API protected by SSL and a shared Key that we'll use to make a query into the Tiggzi project.  By using MongoLab, you can have the benefits of simple connectivity through the https REST interface AND the benefits of a high-performance direct client MongoDB driver when needed, say for log searches or social media analytics.

MongoLab steps

  1. Create a MongoLab account and create a new database and collection if you don't have any yet.  (URL: mongolab.com/signup) The REST API provides access at the database, collection, and document level.  You'll be doing a call from the collection level that will return a JSON array of documents.

  2. Once you're in the collection that you want to expose, click on the "Open API View" button to see a formatted version of what the REST call at the collection level would return.  (The "View raw JSON" button will show the unformatted data).

  3. Right click over the Resource URL and copy it to your clipboard.  You'll notice that it has the properly formed syntax for an entire collection query and includes your apiKey.  Separate out the URL up to the query delimiter '&' and also separate out the apiKey query parameter.  You'll paste it into Tiggzi in a bit.  (Note you can regenerate a new API key by clicking on your username in the upper right header.)

4. If you don't have any documents in the collection, add at least two dummy documents.

Tiggzi steps

  1. Create a new REST Service, by clicking Create new and entering a name in the modal dialog box.

  2. populate the URL in the first screen with the MongoLab REST API URL (without parameters)

  3. in the "Request Parameters" pane, add four parameters: apiKey, q, l, sk (the last three are useful but optional, they are the JSON query parameter, a document count limiter for pagination, and a skip parameter, again for pagination)

4. Fill in the apiKey value with the one you saved.  If your collection is large, you may want to set the limit parameter to something reasonable, say 32.  You can optionally add a query to match only documents you want.

  5. Click Test connection. And then the Test button in the modal dialog box.  What you should get back is an array of the documents in the lower text box.  Now, if everything looks good...

  6. Click "Populate Response Structure" to have Tiggzi extract out a common set of data keys.  You'll get a "Populated successfully." message in green.

7. Save and close this REST Service

  8. Back in the Palette Tab, scroll down to "Services" and drag and drop a REST Service to the Services Component area in the Design view.  (Make sure the Services Component area is expanded.)

You can now wire up the data structure to your mobile app screens as in the Twitter example:  http://help.tiggzi.com/getting-started/building-twitter-search-app

Queries and beyond

  Of course, being able to do full Create Read Update Delete (CRUD) is useful.  Recall that you added three other parameters in the "Request Parameters" screen in Tiggzi Step 3.  One is a query param which takes the MongoDB Javascript query syntax, the other is a limit param ('l') and skip param ('sk') which together will allow you to paginate through a large document set.

And for Create, Update, and Delete, you can formulate a dynamic URL with other http verbs (PUT, POST, DELETE) to handle those actions.  The Tiggzi documentation for doing that is here.  The mapping from the http verbs to MongoLab actions is documented here.

Enjoy!  If you have any problems, of course send email to support@mongolab.com.  Our knowledge base is here.

--------
About Exadel
Exadel provides innovative software using the most advanced technologies including mobile, cloud, and rich Web user interfaces. Founded in 1998, Exadel is privately owned with headquarters in the San Francisco Bay Area. Ourglobal network of development offices has grown to include offices in New York, Chicago, Belarus, Russia, and Ukraine.

I’m MongoLab’s VP of Sales and Marketing. And I’m here to serve our customers’ needs for MongoDB hosting in the cloud.

About benwen

I'm MongoLab's VP of Sales and Marketing. And I'm here to serve our customers' needs for MongoDB hosting in the cloud.