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:









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










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?