USING: accessors assocs fry io.encodings.binary io.sockets kernel math math.parser mongodb.msg mongodb.persistent mongodb.query mongodb.tuple namespaces sequences splitting ; IN: mongodb INTERSECTION: storable mdb-persistent ; > get-collection-fqn ] keep H{ } tuple>query ; inline PRIVATE> : ( db host port -- mdb ) () ; GENERIC: store ( tuple/ht -- ) GENERIC: find ( example -- tuple/ht ) GENERIC: findOne ( exampe -- tuple/ht ) GENERIC: load ( object -- object ) M: storable store ( tuple -- ) prepare-store ! H { collection { ... values ... } [ [ ] 2dip [ get-collection-fqn >>collection ] dip objects>> [ mdb>> master>> binary ] dip '[ _ write-request ] with-client ] assoc-each ; M: storable find ( example -- result ) prepare-find (find) build-result ; M: storable findOne ( example -- result ) prepare-find (find-one) dup returned#>> 1 = [ objects>> first ] [ drop f ] if ;