-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue Description
Hi, everyone! Thank you for your job)
I encoutered an issue. MongoFindOneOptions has wrong where typings, so I can't pass ObjectLiteral to find method.
Maybe I'm doing something wrong.
Expected Behavior
Pass ObjectLiteral in where condition without errors:
return this.repository.find({
where: { someId: { $in: ["id1", "id2"] } },
});Actual Behavior
Type '{ someId: { $in: string[]; }; }' is not assignable to type '((FindOptionsWhere<T> | FindOptionsWhere<T>[]) & (ObjectLiteral | FindOptionsWhere<T> | FindOptionsWhere<...>[])) | undefined'.
Type '{ someId: { $in: string[]; }; }' is not assignable to type 'undefined'.ts(2322)
My Environment
| Dependency | Version |
|---|---|
| Operating System | Ubuntu 20 |
| Node.js version | 16.17.0 |
| Typescript version | 4.7.4 |
| TypeORM version | 0.3.10 |
Additional Context
If I change MongoFindOneOptions from this:
import { FindOneOptions } from "../FindOneOptions"
import { ObjectLiteral } from "../../common/ObjectLiteral"
/**
* Defines a special criteria to find specific entity.
*/
export type MongoFindOneOptions<Entity = any> = FindOneOptions<Entity> & {
/**
* Simple condition that should be applied to match entities.
*/
where?: ObjectLiteral
}to this:
import { FindOneOptions } from "../FindOneOptions"
import { ObjectLiteral } from "../../common/ObjectLiteral"
/**
* Defines a special criteria to find specific entity.
*/
export type MongoFindOneOptions<Entity = any> = Omit<FindOneOptions<Entity>, "where"> & {
/**
* Simple condition that should be applied to match entities.
*/
where?: FindOneOptions<Entity>["where"] | ObjectLiteral;
};The problem is gone:
Relevant Database Driver(s)
| DB Type | Reproducible |
|---|---|
mongodb |
yes |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✅ Yes, I have the time, but I don't know how to start. I would need guidance.
- ✖️ No, I don’t have the time, but I can support (using donations) development.
- ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
sleeyax and svonian

