typeorm
typeorm copied to clipboard
Documentation of find-function in QueryRunner is inaccurate, misleading or wrong
What was unclear or otherwise insufficient?
On this page, there is the following code example:
// we can also access entity manager that works with connection created by a query runner:
const users = await queryRunner.manager.find(User)
While User is not explained at all, what it should be, I tried several attempts:
- Passing a typed UserEntity
- passing a plain object containing corresponding key-value pairs
- passing just
null(for the sake of completeness)
The both first attempts won't compile as the required type can't be fulfilled. Only null went through but makes no sense for sure.
Recommended Fix
Which kind of Data needs to be passed to the find-method?
Please provide a working example.
Additional Context
No response
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, but I don't know how to start. I would need guidance.
i couldn't repreduced what you said by using this code
import { Column, DataSource, Entity, PrimaryColumn } from "typeorm";
@Entity("users")
export class User {
@PrimaryColumn()
id!: number;
@Column()
name: string;
}
const dataSource = new DataSource({
name: "typeorm-bug-10309",
synchronize: true,
logging: false,
type: "mysql",
host: "localhost",
port: 3306,
username: "root",
password: "P@ssw0rd",
database: "typeorm-bug-10309",
entities: [User],
});
dataSource.initialize().then(async () => {
const queryRunner = dataSource.createQueryRunner();
const users = await queryRunner.manager.find(User);
console.log(users);
});
even when using null it didn't pass it gave me this error No metadata for "null" was found if i miss understood what you said please correct me @itinance