Home

Overview

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.

Status

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

Requirements

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)

Installation

For now, grab the code from hg, then cd into the top level dir. fan build.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.

Usage

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

c.insert(["foofoo":345])
obj := c.findOne()
// now, obj["foofoo"] == 345
c.remove(obj)
// 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 (http://www.mongodb.org/display/DOCS/BSON)
  • 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

Todo

in no particular order...

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

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.