MongoDB and $regex queries

I’m trying to query something (anything, actually) using a regex with MongoDB.

Let’s pretend I have a collection of somethings, each document look like this:




{

    path: "/123/456/",

    name: "Test"

}



Now, let’s say I want to query my documents and search for the ones that start with “/555”.




$query = new Query;

$query->select(['name', 'path'])->from('things')->where(["REGEX", "path", "/^/555/"]);

$res = $query->all();



Is that correct? Because I’m not getting any results, but I’m sure I have at least a few documents that start with “/555”.

Also, the MongoDB query monitor tells me the following query is being ran:




find({

    "ns":"todevise.category",

    "limit":0,

    "batchSize":0,

    "skip":0,

    "flags":0,

    "query":{

        "path":{

            "regex":"^/555", // <---- issue?

            "flags":""

        }

    },

    "fields":{

        "short_id":true,

        "path":true

    },

    "started_iterating":false

})



and I can’t find anywhere docs about an operator called “regex” (I do find information about “$regex” thou).

Has anybody managed to get this working?