 USING: io io.encodings.utf8 io.encodings.binary alien.c-types alien.strings math
 bson.writer sequences kernel accessors io.streams.byte-array fry generalizations
-combinators bson.reader sequences tools.walker assocs strings linked-assocs ;
+combinators bson.reader sequences tools.walker assocs strings linked-assocs namespaces ;
 
 IN: mongodb.msg
 

    read-longlong >>cursor
    read-int32 >>start#
    read-int32 [ >>returned# ] keep
    [ H{ } stream>assoc ] accumulator [ times ] dip >>objects ;    

: read-header ( message -- message )
    read-int32 >>length

     ] (write-message) ;
 
M: mdb-insert-msg write-message ( message -- )
    dup
    '[ _
       [ 0 write-int32 ] dip
       [ collection>> write-cstring ] keep
       objects>> [ assoc>array write ] each
    ] (write-message) ;

