-
-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Description
The code works but type show as error at $options
Argument of type '{ $or: ({ username: { $regex: string; $options: string; }; } | { name: { $regex: string; $options: string; }; })[]; } | {}' is not assignable to parameter of type 'Filter<{ provider?: ("google" | "facebook" | "discord" | "email")[] | undefined; devId?: string | ObjectId | undefined; discordId?: string | undefined; avatar?: string | undefined; ... 20 more ...; apps: (string | ObjectId)[]; }> | undefined'.
Type '{ $or: ({ username: { $regex: string; $options: string; }; } | { name: { $regex: string; $options: string; }; })[]; }' is not assignable to type 'Filter<{ provider?: ("google" | "facebook" | "discord" | "email")[] | undefined; devId?: string | ObjectId | undefined; discordId?: string | undefined; avatar?: string | undefined; ... 20 more ...; apps: (string | ObjectId)[]; }>'.
Types of property '$or' are incompatible.
Type '({ username: { $regex: string; $options: string; }; } | { name: { $regex: string; $options: string; }; })[]' is not assignable to type 'Filter<{ provider?: ("google" | "facebook" | "discord" | "email")[] | undefined; devId?: string | ObjectId | undefined; discordId?: string | undefined; avatar?: string | undefined; ... 20 more ...; apps: (string | ObjectId)[]; }>[]'.
Type '{ username: { $regex: string; $options: string; }; } | { name: { $regex: string; $options: string; }; }' is not assignable to type 'Filter<{ provider?: ("google" | "facebook" | "discord" | "email")[] | undefined; devId?: string | ObjectId | undefined; discordId?: string | undefined; avatar?: string | undefined; ... 20 more ...; apps: (string | ObjectId)[]; }>'.
Type '{ username: { $regex: string; $options: string; }; }' is not assignable to type 'Filter<{ provider?: ("google" | "facebook" | "discord" | "email")[] | undefined; devId?: string | ObjectId | undefined; discordId?: string | undefined; avatar?: string | undefined; ... 20 more ...; apps: (string | ObjectId)[]; }>'.
Types of property 'username' are incompatible.
Type '{ $regex: string; $options: string; }' is not assignable to type 'string | FilterOperators<string> | undefined'.
Object literal may only specify known properties, and '$options' does not exist in type 'FilterOperators<string>'.deno-ts(2345)
const users = await Users.find(
search
? {
$or: [
{ username: { $regex: search, $options: "i" } }, // 'i' for case-insensitive
{ name: { $regex: search, $options: "i" } },
],
}
: {},
{
projection: { password: 0 },
}
).toArray();Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels