Index: library/mongodb/nx-mongo.tcl =================================================================== diff -u -ra77464d1f7a06117c621560ec519dc4d387ed5df -r42ba8471f7620b850b6296f753cbc3079fe5c6cd --- library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision a77464d1f7a06117c621560ec519dc4d387ed5df) +++ library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 42ba8471f7620b850b6296f753cbc3079fe5c6cd) @@ -21,7 +21,7 @@ namespace eval ::nx::mongo { ::nx::Object create ::nx::mongo::db { - :property db + :object property db :public object method connect {{-db test} args} { set :db $db set :mongoConn [::mongo::connect {*}$args] @@ -32,7 +32,9 @@ :public object method remove {args} {::mongo::remove ${:mongoConn} {*}$args} :public object method query {args} {::mongo::query ${:mongoConn} {*}$args} :public object method update {args} {::mongo::update ${:mongoConn} {*}$args} - :public object method "drop collection" {name} {::mongo::run ${:mongoConn} ${:db} [list drop string $name]} + :public object method "drop collection" {name} {::mongo::run -nocomplain ${:mongoConn} ${:db} [list drop string $name]} + :public object method "drop database" {} {::mongo::run -nocomplain ${:mongoConn} ${:db} [list dropDatabase integer 1]} + :public object method "reset error" {} {::mongo::run -nocomplain ${:mongoConn} ${:db} [list reseterror integer 1]} } ####################################################################### @@ -121,7 +123,7 @@ puts stderr "autosave $value to obtain an object_id" $value save } - set _id [$value _id] + set _id [$value cget -_id] set cls [$value info class] return [list object [list \ {$ref} string [$cls mongo_collection] \ @@ -221,7 +223,7 @@ :method "get slot" {att} { set classes [concat [self] [:info mixin classes] [:info heritage]] foreach cls $classes { - set slot [$cls info slot objects $att] + set slot [$cls info slots $att] if {$slot ne ""} { return $slot } @@ -249,9 +251,9 @@ set slot [:get slot $att] if {$slot eq ""} {error "could not obtain slot for <$att $op $value>"} switch $op { - "=" {lappend bson $att [$slot mongotype] $value} + "=" {lappend bson $att [$slot cget -mongotype] $value} ">" - "<" - "<=" - ">=" - "!=" { - lappend bson $att object [list [:get relop $op] [$slot mongotype] $value] + lappend bson $att object [list [:get relop $op] [$slot cget -mongotype] $value] } "in" - "all" { lappend bson $att object [list [:get relop $op] {*}[$slot bson encode -array $value]] @@ -367,7 +369,7 @@ :public method insert {args} { set p [:new {*}$args] $p save - set _id [$p _id] + set _id [$p cget -_id] $p destroy return $_id } @@ -457,7 +459,7 @@ set :mongo_collection [string tolower [namespace tail [self]]]s } if {![info exists :mongo_db]} { - set :mongo_db [::nx::mongo::db db] + set :mongo_db [::nx::mongo::db cget -db] } set :mongo_ns ${:mongo_db}.${:mongo_collection} #puts stderr "mongo_ns is set to ${:mongo_ns}" @@ -555,7 +557,7 @@ } else { #puts "delete a non-embedded entry" if {[info exists :_id]} { - set mongo_ns [[:info class] mongo_ns] + set mongo_ns [[:info class] cget -mongo_ns] ::nx::mongo::db remove $mongo_ns [list _id oid ${:_id}] } else { error "[self]: object does not contain an _id; it can't be delete from the mongo db." @@ -568,7 +570,7 @@ # otherwise perform an insert # :public method save {} { - set mongo_ns [[:info class] mongo_ns] + set mongo_ns [[:info class] cget -mongo_ns] if {$mongo_ns eq ""} { # We could perform the delegation probably automatically, but # for now we provide an error