OBP-API/MavLift/README

60 lines
1.9 KiB
Plaintext
Raw Normal View History

2011-10-16 13:40:36 +00:00
This project contains some try outs so far.
The project is using Maven 2 as a build tool. See pom.xml for the dependancies.
I used IntelliJ IDEA as my IDE. It has nice autocompletion.
To run, cd into the root directory (where this file is) and run:
mvn jetty:run
2011-10-16 14:30:22 +00:00
Note: You may need to add the pluginGroup to the $HOME/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>
...
</settings>
2011-10-16 13:40:36 +00:00
To test one of the URL's use:
curl http://localhost:8080/mongodb
Other important files:
Boot.scala
SomeThing.scala - This file contains the URL routes (like urls.py) and my try outs- See serve case Req
I tried several approaches for scala talking to mongodb
Lift Record: works for inserts and simple (inc geo) queries. but i couldn't figure out how to sort.
Rogue: I got this to import but couldn't get the "where" syntax to compile.
Casbah: works including sorting. :-)
Casbah is the officialy supported Scala driver for MongoDB. It is a thin wrapper for the Java driver which is very well used
so I guess its a good choice at least until we understand how to use Lift Record/ Rogue better.
We can still use Lift Record for inserts etc.
It also has a full time developer working on it. The documentation tends to lack examples, but this helps:
https://github.com/mongodb/casbah/blob/master/casbah-query/src/test/scala/DSLCoreOperatorsSpec.scala#L861-984
You'll also need to add the import statement to get the query syntax:
import com.mongodb.casbah.query.Imports._
To start mongodb
sudo mongod
Note: you might want to look at the mongo data from the mongo command line:
db.chooseitems.find( { location : { $near : [2,2] } } )
etc.
2011-10-16 14:30:22 +00:00
s.r.