Home

rbarooah edited this page Sep 13, 2010 · 14 revisions
Clone this wiki locally

Sublime SimpleDB

SimpleDB binding for Scala

A lightweight and easy to use interface to Amazon’s SimpleDB web service, designed to complement Scala’s expressiveness.

Discussion Here: Google Group

Bug tracking here: Lighthouse Bug Tracker

Documentation Here: ScalaDocs
(Hint: All of the stuff you need is in the SimpleAPI trait…)

How to use

Either clone the repository and then mvn install, or: download the prebuilt jar

If you build with maven, the dependencies will be installed automatically otherwise you’ll need commons-codec and apache-httpclient on your classpath.

Some examples

Import the API Classes:

import org.sublime.amazon.simpleDB.api._

Create an account object representing your Amazon AWS account.:

val account = new SimpleDBAccount( <keyId>, <key> )

Import the symbols from the account for convenience:

import account._

Create a domain called ‘test’:

domain ("test") create

Add an attribute called “role” with a value “author” to the item named “robin”:

domain ("test") item ("robin") += ("role" -> "author")

Add an attribute called “role” with a value “reviewer” to the item named “landon”:

domain ("test") item ("landon") += ("role" -> "reviewer")

Print the names of the items in the ‘test’ domain who’s role is ‘reviewer’:

select (" * from test where role='reviewer'") foreach ( e => println(e.name))

Set the ‘score’ attribute of every ‘reviewer’ to ‘2’:

select (" * from test where role='reviewer'") foreach ( e => domain ("test") item (e) set ("score" -> "2"))

Documentation Here: ScalaDocs
(Hint: All of the stuff you need is in the SimpleAPI trait…)

Discussion Here: Google Group