1 USING: help.markup help.syntax ;
4 ARTICLE: "mongodb" "MongoDB factor integration"
5 "The " { $vocab-link "mongodb" } " vocabulary provides two different interfaces to the MongoDB document-oriented database"
6 { $heading "Low-level driver" }
7 "The " { $vocab-link "mongodb.driver" } " vocabulary provides a low-level interface to MongoDB."
9 "USING: mongodb.driver ;"
10 "\"db\" \"127.0.0.1\" 27017 <mdb>"
11 "[ \"mycollection\" [ H{ { \"name\" \"Alfred\" } { \"age\" 57 } } save ] "
12 " [ \"ageIdx\" [ \"age\" asc ] key-spec <index-spec> ensure-index ]"
13 " [ H{ { \"age\" H{ { \"$gt\" 50 } } } } <query> find-one ] tri ] with-db "
15 { $heading "Highlevel tuple integration" }
16 "The " { $vocab-link "mongodb.tuple" } " vocabulary lets you define persistent tuples that can be stored to and retrieved from a MongoDB database"
18 "USING: mongodb.driver mongodb.tuple fry literals ;"
19 "MDBTUPLE: person name age ; "
20 "person \"persons\" { } { $[ \"ageIdx\" [ \"age\" asc ] key-spec <tuple-index> ] } define-persistent "
21 "\"db\" \"127.0.0.1\" 27017 <mdb>"
22 "person new \"Alfred\" >>name 57 >>age"
23 "'[ person ensure-table _ save-tuple person new 57 >>age select-tuple ] with-db"