late-ambulance-66508
08/06/2026, 8:14 AMmod operator in SDK?
{
"attribute": {
"$mod": [
2,
1
]
}
}powerful-spoon-16837
08/06/2026, 8:57 AMlate-ambulance-66508
08/06/2026, 9:29 AM[02468]$ in advanced JSON mode?powerful-spoon-16837
08/06/2026, 11:20 AM1.1.12), with id passed as a numeric attribute:
{ "id": { "$regex": "[02468]$" } }
Both JS and Swift coerce the attribute to a string before matching (Swift via stringValue, J_S via RegExp.test()_), so it works whether your id is a string or a number.
Three caveats:
1. It only covers divisors of powers of 10. Trailing digits give you $mod [2,x], [5,x], [10,x], [100,x] ("00$"), but there's no regex equivalent for [3,1] or [7,2] — divisibility by 3 or 7 isn't determined by the last digits. It's also not exact at the low end: "07$" won't match id = 7, even though 7 % 100 == 7.
2. You only get a 50/50 split if your IDs are decimal numbers. If id is a UUID, the last character is hex (0-9a-f), so [02468]$ matches 5 of 16 possible characters — roughly 31%, not 50%. For UUIDs use [02468ace]$ (8 of 16) to get an even split.
3. Don't drop the $ anchor. $regex is an unanchored search, so [02468] on its own matches any ID containing an even digit anywhere — which is nearly all of them.
And if what you actually need is a stable percentage split rather than the arithmetic property itself, coverage + hashAttribute is the better tool — it's uniform regardless of ID format and doesn't depend on IDs being sequential or gap-free. @late-ambulance-66508late-ambulance-66508
08/06/2026, 11:21 AM