denodrivers / denodrivers/mongo
no $option in FilterOperators for $regex?
- Dominant language
- TypeScript
- Stars
- 511
- Forks
- 89
- PR merge metrics
- No merged PRs in 30d
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 | undefined'.
Object literal may only specify known properties, and '$options' does not exist in type 'FilterOperators'.deno-ts(2345)
```
```ts
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();
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.