I have this document collection:
{
_id: 3,
version: "v1_8_R2"
},
{
_id: 2,
version: "v1_8"
}
{
_id: 1,
version: "v1_8_R3"
}
Using db.coll.find({version:"v1_8_R3"}) I get the id: 1 document, but id: 2 is compatible with the v1_8_R3 version and the id: 1 is outdated, and I don't want v1_8_R2 to be matched since it's incompatible with v1_8_R3
With regex I could solve that, but mongo doesn't allow to use it in fields unlike mysql
This works, but the other way around: db.coll.find(version: {$regex: "v1_8_R3", $options: "i"})
I would need something like this: db.coll.find({$regex: version, $options: "i"}: "v1_8_R3")
Then it would match v1_8, and wouldn't match v1_8_R2
versionas a regex?v1_8andv1_8_R3, you may use a"^v1_8(?:_R3)?$"regex