Index: TODO =================================================================== diff -u -r00c40339a2fee2c2416a881d19b61e3aa92e963d -r47a15b921dd9cd528789a2ae33a3eb841f7356c2 --- TODO (.../TODO) (revision 00c40339a2fee2c2416a881d19b61e3aa92e963d) +++ TODO (.../TODO) (revision 47a15b921dd9cd528789a2ae33a3eb841f7356c2) @@ -4790,6 +4790,9 @@ - add more assertions - ensure computation of requires orders for recursive merges +mongodb +- add flag "-puts" to method "show" of nx::mongo::Class to turnoff + output to stdout ======================================================================== TODO: Index: library/mongodb/nx-mongo.tcl =================================================================== diff -u -r5c3834b15078b31970db26d0c65030ed1f66b18d -r47a15b921dd9cd528789a2ae33a3eb841f7356c2 --- library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 5c3834b15078b31970db26d0c65030ed1f66b18d) +++ library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 47a15b921dd9cd528789a2ae33a3eb841f7356c2) @@ -29,6 +29,7 @@ set :db $db set :mongoConn [::mongo::connect {*}$args] } + :public object method close {} {::mongo::close ${:mongoConn}} :public object method count {args} {::mongo::count ${:mongoConn} {*}$args} :public object method index {args} {::mongo::index ${:mongoConn} {*}$args} :public object method insert {args} {::mongo::insert ${:mongoConn} {*}$args} @@ -325,6 +326,7 @@ if {$name ne ""} { return [:create $name {*}[:bson parameter $tuple]] } else { + #puts "CREATE new [self] <$tuple>" return [:new {*}[:bson parameter $tuple]] } } @@ -368,6 +370,30 @@ regsub -all {,type=} $spec {,arg=} spec next [list -class $class -incremental=$incremental $spec $initblock] } + + :public method pretty_variables {} { + set vars {} + foreach p [lmap handle [lsort [:info variables]] {::nx::Object info variable parameter $handle}] { + if {[regexp {^([^:]+):(.*)$} $p _ name options]} { + set resultOptions {} + set opts [split $options ,] + if {[lindex $opts 0] eq "embedded"} { + set resultOpts {} + foreach opt $opts { + switch -glob $opt { + slot=* {continue} + arg=* {lappend resultOpts type=[string range $opt 4 end]} + default {lappend resultOpts $opt} + } + } + lappend vars $name:[join $resultOpts ,] + continue + } + } + lappend vars $p + } + return $vars + } # # index method @@ -412,7 +438,9 @@ [:bson query -cond $cond -orderby $orderby] \ -atts [:bson atts $atts] \ -limit 1] 0] - #puts "find first fetched: $tuple" + if {$tuple eq ""} { + return "" + } if {$instance ne ""} {set instance [:uplevel [list ::nsf::object::qualify $instance]]} return [:bson create -name $instance $tuple] } @@ -432,7 +460,7 @@ [:bson query -cond $cond -orderby $orderby] \ -atts [:bson atts $atts] \ {*}$opts] - #puts "[join $fetched \n]" + foreach tuple $fetched { lappend result [:bson create $tuple] } @@ -445,8 +473,8 @@ {-orderby ""} {-limit} {-skip} + {-puts:boolean 1} } { - set result [list] set opts [list] if {[info exists limit]} {lappend opts -limit $limit} if {[info exists skip]} {lappend opts -skip $skip} @@ -458,7 +486,8 @@ foreach tuple $fetched { lappend tuples "\{[:bson pp -indent 4 $tuple]\n\}" } - puts [join $tuples ", "] + if {$puts} {puts [join $tuples ", "]} + return $tuples } :method mongo_setup {} {