MongoDB factor integration - Factor Documentation (original) (raw)
The mongodb vocabulary provides two different interfaces to the MongoDB document-oriented database
Low-level driver
The mongodb.driver vocabulary provides a low-level interface to MongoDB.
USING: mongodb.driver ; "db" "127.0.0.1" 27017 [ "mycollection" [ H{ { "name" "Alfred" } { "age" 57 } } save ] [ "ageIdx" [ "age" asc ] key-spec ensure-index ] [ H{ { "age" H{ { "$gt" 50 } } } } find-one ] tri ] with-db
Highlevel tuple integration
The mongodb.tuple vocabulary lets you define persistent tuples that can be stored to and retrieved from a MongoDB database
USING: mongodb.driver mongodb.tuple fry literals ; MDBTUPLE: person name age ; person "persons" { } { $[ "ageIdx" [ "age" asc ] key-spec ] } define-persistent "db" "127.0.0.1" 27017 person new "Alfred" >>name 57 >>age '[ person ensure-table _ save-tuple person new 57 >>age select-tuple ] with-db