Can I use traits to find users in kratos? I'm crea...
# ory-selfhosting
f
Can I use traits to find users in kratos? I'm creating an admin page, and I've been asked to make it possible to search for users by traits (join date, department, etc). I am looking for another way to do it, because using credentials_identifier requires knowing the identifier exactly.
t
I don't think it's possible natively. Two options come to mind 1. Use the list identities endpoint, and do your own filtering on the results, although probably doesn't scale well if you're dealing with thousands of identities. 2. Create your own data dictionary, which you use to perform your search against, and return the relevant identity ID. You'd need to use the Kratos webhooks to keep the dictionary in-sync too.
a
Why not just query the database directly?
t
That's generally bad practice. What if the scheme changes in a Kratos update? You're then depending on things always being in the same format to be able to have your code query it