Search users
Import the function at the top of your file
import { searchUsers } from "swizzle-js";Search for users with searchUsers(queryObject)
The queryObject is a MongoDB formatted find query. The most common way to use this is to search for {"key": "searchQuery"}. Some examples:
To search for users that have the property
isAdminset to true, you'd pass{"isAdmin": true}To search for users that have the property
ageless than 21, you'd pass{ "age": { $lt: 21 } }To search for users that have the property description containing the words "late", you'd pass
{ description: { $regex: /late/, $options: 'i' } }
You can read more on the MongoDB documentation, or ask Swizzle assistant/ChatGPT to write a mongo query for you.
const matchingUserArray = await searchUsers({"property": "query"})Last updated