Hello world example.

21 views
Skip to first unread message

fernanda.aispuro

unread,
Jul 30, 2009, 1:38:03 AM7/30/09
to Sublime SimpleDB
Noob trying out both AWS simpleDb and scala.
I'm trying to simply create a domain, attach some properties and then
read all the data.
Here is what I have:

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

object MyApp extends Application {
val account = new SimpleDBAccount("XXXXXXXXXXX", "XXXXXXXXXXX")
domain ("test") create
domain ("test") item ("robin") += ("role" -> "author")
domain ("test") item ("landon") += ("role" -> "reviewer")
select ("select * from test where role='reviewer'") foreach ( e
=> println(e.name))
select ("select * from test where role='reviewer'") foreach ( e
=> domain ("test") item (e) set ("score" -> "2"))
}

The problem is that it does not find domain. What am I doing wrong?

Robin Barooah

unread,
Jul 30, 2009, 2:34:14 PM7/30/09
to Sublime SimpleDB


On Jul 29, 10:38 pm, "fernanda.aispuro" <fernanda.aisp...@gmail.com>
wrote:
> Noob trying out both AWS simpleDb and scala.
> I'm trying to simply create a domain, attach some properties and then
> read all the data.
> Here is what I have:
>

I think this line:

> import org.sublime.amazon.simpleDB.api.SimpleAPI

Should be like this:

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

You can then omit these two lines:

> import org.sublime.amazon.simpleDB.api.SimpleDBAccount
> import org.sublime.amazon.simpleDB._
>
> object MyApp extends Application {
> val account = new SimpleDBAccount("XXXXXXXXXXX",  "XXXXXXXXXXX")
>  domain ("test") create
>       domain ("test") item ("robin") += ("role" -> "author")
>       domain ("test") item ("landon") += ("role" -> "reviewer")
>       select ("select * from test where role='reviewer'") foreach ( e
> => println(e.name))
>       select ("select * from test where role='reviewer'") foreach ( e
> => domain ("test") item (e) set ("score" -> "2"))
>
> }
>
> The problem is that it does not find domain. What am I doing wrong?

Thanks for trying it. Let me know how you get on. I have added some
interesting new features since I wrote up the example. In particular
there are now type-safe conversions for things like numbers and dates,
and a dsl for constructing queries in a composable and type safe
manner. Currently these are only documented in the source though. I
plan to update the examples and scaladoc on github soon.

-Robin

fernanda.aispuro

unread,
Jul 31, 2009, 7:58:11 PM7/31/09
to Sublime SimpleDB
Hi Robin,

I tried doing what you suggested. This is my Hello.scala:


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

object Hello extends Application {
override def main(args:Array[String]) = {
println("Hello world")
val account = new SimpleDBAccount( "XXX", "XXX" )
domain ("test") create
}
}

Ant this is the result:


scalac -classpath
./lib/commons-codec-1.3.jar:./lib/commons-httpclient-3.1.jar:./lib/
commons-logging-1.1.1.jar:./lib/commons-pool-1.5.2.jar:./lib/sublime-
simpleDB-0.9-SNAPSHOT.jar:./lib/junit-4.0.jar
./src/Hello.scala
./src/Hello.scala:17: error: not found: value domain
domain ("test") create
^
one error found


I've tried both using Itellij IDE and manual compilation , they yield
the same error: not finding "domain".
Any ideas?
Thanks

Robin

unread,
Aug 3, 2009, 1:59:18 AM8/3/09
to sublime-...@googlegroups.com
Sorry, I missed the actual problem, although by now, your friend Mateo will probably have told you - this should work:

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

     object Hello extends Application {
         override def main(args:Array[String]) = {
         println("Hello world")
        val account = new SimpleDBAccount( "XXX", "XXX" )
        
        
        // so this should be:
        val test = account domain ("test")
        test create
        
        // create is idempotent - if you're sure it's already created, you don't need to do it
        
        // if you do
        import account._
        
        
        // then this should actually work:
--
-Robin

Robin Barooah
http://www.sublime.org

fernanda.aispuro

unread,
Aug 3, 2009, 5:55:35 PM8/3/09
to Sublime SimpleDB
Hi Robin,

Yes, Mateo passed on the answer.
We might come back to you with more questions as we move forward :)
Thanks for your help.
Reply all
Reply to author
Forward
0 new messages