Clone wiki

fantomongo / Home


Fantom is a great language that runs nice and quickly on the JVM. MongoDB is an excellent schema-free document oriented database. Rather than wrap the existing Java drivers, I decided to create a pure Fantom driver implementation, both to learn Fantom better and to learn more about Mongo's internals.


This project is still pretty new. Definitely not being used in any production capacity as of yet, but the test coverage is getting better all the time, and the code has remained relatively simple. Please don't hesitate to submit bug reports or (even better!) pull requests.

Quick Start


Fortunately not much - a Fantom 1.0.53 or later installation, and MongoDB (I've been testing against 1.1.4, you'll definitely want to run the test suite to see how it works with more recent releases until I get a chance to update myself)


For now, grab the code from hg, then cd into the top level dir. fan and you're good to go - mongo.pod has been added to your system. Just add using mongo at the top of a file/script in which you'd like to use it.


// insert
m := Mongo()
db := m.db("mytestdb")
c := db["mycollection"]

obj := c.findOne()
// now, obj["foofoo"] == 345
// now, c.find().count == 0

For now, the best way to get into it is to go through the source and the tests. Once I figure out a good place to host some of the fandoc reference material, I'll add that as well.

Existing Features

  • BSON serialization/deserialization for most types (
  • single and bulk insert
  • querying w/sort, limit and skip
  • count on cursors
  • remove/delete
  • group, distinct
  • a variety of DB commands
  • authentication and user management
  • connection management (sort of...can probably be improved upon)
  • GridFS - stream-oriented storage of arbitrarily large files
  • Map/Reduce


in no particular order...

  • replica pairs / sharding support
  • always more tests
  • hint/$where
  • auto-reconnect