Index: library/mongodb/nx-mongo.tcl =================================================================== diff -u -r4028b984af21ce2b0232ed8cb46572dc8336c76b -r788f2f577d21a28e0d6a05ca87562a507d929527 --- library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 4028b984af21ce2b0232ed8cb46572dc8336c76b) +++ library/mongodb/nx-mongo.tcl (.../nx-mongo.tcl) (revision 788f2f577d21a28e0d6a05ca87562a507d929527) @@ -454,6 +454,11 @@ "in" - "all" { lappend bson $att document [list [:get relop $op] {*}[$slot bson encode -array $value]] } + "~" { + # value should be a two-element list contain pattern and options + lappend bson $att document [list {$regex} regex $value] + } + default {return -code error "unknown operator $op"} } } Index: library/mongodb/tests/nx-mongo.test =================================================================== diff -u -rab21c8502870e715c567c657146283699e31b01b -r788f2f577d21a28e0d6a05ca87562a507d929527 --- library/mongodb/tests/nx-mongo.test (.../nx-mongo.test) (revision ab21c8502870e715c567c657146283699e31b01b) +++ library/mongodb/tests/nx-mongo.test (.../nx-mongo.test) (revision 788f2f577d21a28e0d6a05ca87562a507d929527) @@ -115,6 +115,9 @@ ? {llength [set persons [Person find all -cond {age > 30}]]} 1 ? {lsort [lmap p $persons {$p cget -name}]} "Gustaf" +puts "\nFind persons with names matching regular expression /an/i (containing 'an', ignore case):" +? {llength [set persons [Person find all -cond {name ~ {an i}}]]} 2 +? {lsort [lmap p $persons {$p cget -name}]} "Franz Stefan" # # Define a special find method for "Person" named "oldies" by @@ -124,6 +127,7 @@ return [:find all -cond {age > 30}] } + # # Use the special find method #