Hi,

as an exercise in Factor (my new favorite language :-) ) I wrote a
driver for the MongoDB (http://www.mongodb.org) database.

The code is available via GitHub
(https://github.com/x6j8x/mongo-factor-driver/tree;
git://github.com/x6j8x/mongo-factor-driver.git). Just clone the
repository and add the directory to your ~/.factor-roots file.

Here's a short example of how to use the driver:

USE: mongodb.driver

! 1. initialize mdb
! database host port <mdb>
"db" "127.0.0.1" 27017 <mdb>

! 2. create an index
! <mdb> [ collection name spec ensure-index ] with-db
dup [ "test" "idIdx" H{ { "_id" 1 } } ensure-index ] with-db

! 3. insert an object
! <mdb> [ collection object save ] with-db
dup [ "test" H{ { "_id" "12345" } { "name" "myobject" } } save ] with-db

! 4. find the object
! <mdb> [ collection example <query> ..options.. find ] with-db
dup [ "test" H{ { "_id" "12345" } } <query> find ] with-db

! a find with options would look like this

dup [ "test" H{ { "name" "myobject" } } <query> 10 limit [ "_id" asc
"name" desc ] sort find ] with-db

Unfortunately the code isn't documented ( yet ).

Sascha
--
Through the darkness of future past
the magician longs to see
One chants out between two worlds
Fire walk with me.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to