changed find, update and get-more

db4
Sascha Matzke 2009-03-11 14:40:07 +01:00
parent 536933fafc
commit 2a29d7fed4
2 changed files with 21 additions and 13 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*~

View File

@ -204,18 +204,21 @@ GENERIC# hint 1 ( mdb-query index-hint -- mdb-query )
M: mdb-query-msg hint ( mdb-query index-hint -- mdb-query ) M: mdb-query-msg hint ( mdb-query index-hint -- mdb-query )
>>hint ; >>hint ;
GENERIC: get-more ( mdb-cursor -- mdb-cursor objects )
M: mdb-cursor get-more ( mdb-cursor -- mdb-cursor objects )
[ [ collection>> ] [ return#>> ] [ id>> ] tri <mdb-getmore-msg> send-query ]
[ f f ] if* ;
GENERIC: find ( mdb-query -- cursor result ) GENERIC: find ( mdb-query -- cursor result )
M: mdb-query-msg find M: mdb-query-msg find
send-query ; send-query ;
M: mdb-cursor find
get-more ;
GENERIC: explain ( mdb-query -- result ) GENERIC: explain ( mdb-query -- result )
M: mdb-query-msg explain M: mdb-query-msg explain
t >>explain find [ drop ] dip ; t >>explain find [ drop ] dip ;
GENERIC: get-more ( mdb-cursor -- mdb-cursor objects )
M: mdb-cursor get-more ( mdb-cursor -- mdb-cursor objects )
[ [ collection>> ] [ return#>> ] [ id>> ] tri <mdb-getmore-msg> send-query ]
[ f f ] if* ;
GENERIC: find-one ( mdb-query -- result ) GENERIC: find-one ( mdb-query -- result )
M: mdb-query-msg find-one M: mdb-query-msg find-one
@ -275,15 +278,19 @@ M: assoc ensure-index
[ cmd-collection ] dip <mdb-query-msg> find-one objects>> first [ cmd-collection ] dip <mdb-query-msg> find-one objects>> first
check-ok [ "could not drop index" throw ] unless ; check-ok [ "could not drop index" throw ] unless ;
GENERIC: update ( collection selector object -- ) : <update> ( collection selector object -- update-msg )
M: assoc update [ ensure-collection ] 2dip <mdb-update-msg> ;
[ ensure-collection ] dip
<mdb-update-msg> send-message-check-error ;
GENERIC: update-unsafe ( collection selector object -- ) : >upsert ( mdb-update-msg -- mdb-update-msg )
M: assoc update-unsafe 1 >>upsert? ;
[ ensure-collection ] dip
<mdb-update-msg> send-message ; GENERIC: update ( mdb-update-msg -- )
M: mdb-update-msg update
send-message-check-error ;
GENERIC: update-unsafe ( mdb-update-msg -- )
M: mdb-update-msg update-unsafe
send-message ;
GENERIC: delete ( collection selector -- ) GENERIC: delete ( collection selector -- )
M: assoc delete M: assoc delete