Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Query 2 - (Regular Expressions Support) #4

Open
fvonschrenk opened this Issue Oct 7, 2011 · 2 comments

Comments

Projects
None yet
2 participants

regex runs don't use /xxx/

db.num.find();
{ "_id" : ObjectId("4e8ef812a3963e830a27360a"), "value" : 1 }
{ "_id" : ObjectId("4e8ef818a3963e830a27360b"), "value" : 2 }
{ "_id" : ObjectId("4e8ef81ba3963e830a27360c"), "value" : 3 }
{ "_id" : ObjectId("4e8ef81fa3963e830a27360d"), "value" : 4 }
{ "_id" : ObjectId("4e8ef825a3963e830a27360e"), "value" : 5 }
{ "_id" : ObjectId("4e8ef82ba3963e830a27360f"), "value" : 6 }
{ "_id" : ObjectId("4e8ef82ea3963e830a273610"), "value" : 7 }
{ "_id" : ObjectId("4e8ef831a3963e830a273611"), "value" : 8 }
{ "_id" : ObjectId("4e8f5674a3963e830a273616"), "value" : 9, "value1" : 9, "value2" : "Frank" }

    private function reg(cursor:Cursor):void{
        if (cursor.toArray().length==2){
            dispatch(new TestEvent(TestEvent.PASS,"pass   $or"));
        }else{
            dispatch(new TestEvent(TestEvent.FAULT,"fault  $or"));
        }

        var docOut:Document = new Document(); 
        var docIn:Document = new Document(); 

        docOut.put("$regex", "ra");
        docIn.put("value2",docOut);

        dm.db.collection("num").find(docIn).add(enda);
    }

    private function enda(cursor:Cursor):void{
        if (cursor.toArray().length==1){
            dispatch(new TestEvent(TestEvent.PASS,"pass   $regex"));
        }else{
            dispatch(new TestEvent(TestEvent.FAULT,"fault  $regex"));
        }
    }

pass $gt
pass $lt
pass $gte
pass $lte
pass $all
pass $nin
pass $or
pass $regex

Owner

s9tpepper commented Oct 8, 2011

I think it still needs some work so you can actually do something like:

var docOut:Document = new Document(); 
var docIn:Document = new Document(); 

var myRegex:RegEx = /ra/i;
docOut.put("$regex", myRegex);
docIn.put("value2",docOut);

dm.db.collection("num").find(docIn).add(enda);

This way you can set up more complicated regular expressions and use the flags that are supported by MongoDB. Maybe there's a way to do it with the current support, but I need to properly add support for regular expressions still.

@ghost ghost assigned s9tpepper Oct 8, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment