Comparing string keys with greater than and less than?
Hi there. Let say I have some feature toggle flag that is working with account ids. Account id is an MongoDB's ObjectId() string representation.
MongoDB's ObjectId can be sorted, and as result, compared.
if ('60339d46235ea9002f4eea4f' > '6033a4a8daec6c3ff161080d') {
}
As I understand, split.io doesn't have the ability to compare strings. Do you have any plans to implement it?
Do I have another simple way to be able to compare strings?
The whole idea is to be able to enable some feature for a specific account id in one case. In another case, I want to be able to enable it only for new accounts. New accounts can be defined as just accounts with ID that are less than ID generated today for example.
The point is that I want to have in the code simple check like ft.isEnable(name, accountId), and will have the ability to create these two strategies of comparing. The equal (per account id) or for new accounts only (by comparing to some pre-generated id).
Thanks!
-
Hi Alexander, From Split UI, you can use "select matcher->String->is in List" for targeting rule custom attribute, then create attribute object in your code, this will compare the attribute string in the code to the list of strings added to the UI.
Checkout the corresponding SDK doc for a code example using custom attribute.
Thanks
Bilal
-
Bilal Al-Shahwany Tnx, but I'm asking for something different. Testing attribute against a list of values is easy. But when I already have 10k accounts, I don't think this is a good solution to create a list of 10k account ids, and then checking if my attribute is not on this list, to emulate "enable only for new accounts" behavior.
Looks like I must do it in the code, by explicitly providing account registration date to split, and use date comparing, of integers in case of passing timestamp.
Tnx anyway :)
Please sign in to leave a comment.
Comments
3 comments