OBP-API/MavLift
2011-10-17 17:11:51 +02:00
..
.idea Initial checkin of try out code 2011-10-16 15:40:36 +02:00
src Maybe this will work better now 2011-10-17 17:11:51 +02:00
.DS_Store Initial checkin of try out code 2011-10-16 15:40:36 +02:00
MavLift.iml Initial checkin of try out code 2011-10-16 15:40:36 +02:00
obp_api.iml Initial checkin of try out code 2011-10-16 15:40:36 +02:00
pom.xml Initial checkin of try out code 2011-10-16 15:40:36 +02:00
README Added Note in README 2011-10-16 16:30:22 +02: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


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>


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.


 s.r.