Permalink
Browse files

added query and delete options

  • Loading branch information...
1 parent b825c2f commit 5200e9d78b24b7280f14a91ffd86ae21d295420f @x6j8x x6j8x committed Jul 31, 2010
@@ -185,6 +185,15 @@ PRIVATE>
: <query> ( collection assoc -- mdb-query-msg )
<mdb-query-msg> ; inline
+: >slave-ok ( mdb-query-msg -- mdb-query-msg )
+ [ 2 set-bit ] change-flags ;
+
+: >await-data ( mdb-query-msg -- mdb-query-msg )
+ [ 5 set-bit ] change-flags ;
+
+: >tailable ( mdb-query-msg -- mdb-query-msg )
+ [ 1 set-bit ] change-flags ;
+
: limit ( mdb-query-msg limit# -- mdb-query-msg )
>>return# ; inline
@@ -299,13 +308,17 @@ PRIVATE>
: run-cmd ( cmd -- result )
send-cmd ; inline
-: delete ( collection selector -- )
- [ check-collection ] dip
- <mdb-delete-msg> send-message-check-error ;
+: <delete> ( collection selector -- mdb-delete-msg )
+ [ check-collection ] dip <mdb-delete-msg> ;
-: delete-unsafe ( collection selector -- )
- [ check-collection ] dip
- <mdb-delete-msg> send-message ;
+: >single-remove ( mdb-delete-msg -- mdb-delete-msg )
+ [ 0 set-bit ] change-delete-flags ;
+
+: delete ( mdb-delete-msg -- )
+ send-message-check-error ;
+
+: delete-unsafe ( mdb-delete-msg -- )
+ send-message ;
: kill-cursor ( mdb-cursor -- )
id>> <mdb-killcursors-msg> send-message ;
@@ -44,6 +44,7 @@ TUPLE: mdb-update-msg < mdb-msg
TUPLE: mdb-delete-msg < mdb-msg
{ collection string }
+ { delete-flags integer initial: 0 }
{ selector assoc } ;
TUPLE: mdb-getmore-msg < mdb-msg
@@ -128,9 +128,12 @@ PRIVATE>
: write-delete-message ( message -- )
[
- [ flags>> write-int32 ]
- [ collection>> write-cstring ]
- [ 0 write-int32 selector>> assoc>stream ] tri
+ {
+ [ flags>> write-int32 ]
+ [ collection>> write-cstring ]
+ [ delete-flags>> write-int32 ]
+ [ selector>> assoc>stream ]
+ } cleave
] (write-message) ; inline
: write-getmore-message ( message -- )
@@ -73,7 +73,7 @@ PRIVATE>
: delete-tuple ( tuple -- )
[ tuple-collection name>> ] keep
- id-selector delete ;
+ id-selector <delete> delete ;
: delete-tuples ( seq -- )
[ delete-tuple ] each ;

0 comments on commit 5200e9d

Please sign in to comment.