loadRelationIds produces incorrect type?
See original GitHub issueIssue type:
[ ] question [x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ] latest
[ ] @next
[x] 0.2.18
(or put your version here)
Steps to reproduce:
If I am using the loadRelationIds
feature like this:
const orders = await manager.find(Order, {
where: {
// conditions
},
loadEagerRelations: false,
loadRelationIds: {
relations: [
'customer',
],
},
});
then the type of Order.customer
in the orders
array is still the entire Customer
entity/object, while in fact it is just a string, the customer ID.
Is this expected or is this a bug? It seems that the return type of manager.find
should be modified when loadRelationIds
is set, and Order.customer
should become a string instead of an object.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Relations | TypeORM Docs
When we set @JoinColumn , it automatically creates a column in the database named propertyName + referencedColumnName . For example: @ManyToOne(type => Category ......
Read more >Using TypeScript with the MySQL Database - InfoQ
Problem. JavaScript lacks several features that are used by large-scale ... Creates a primary column of type int that is automatically ...
Read more >Class Connection - typeorm
Connection is a single database ORM connection to a specific database. Its not required to be a database connection, depend on database type...
Read more >TypeORM: Load relations with only certain specified fields
That being said, if you have the correct OneToMany relation setup in your entity @OneToMany(type => Post, post => post.user) posts: Post.
Read more >Nest + gql + typeORM(@nestjs/typeorm) (7) typeORM ...
Ride entity @OneToOne((type) => Chat, (chat) => chat.ride, ... 생략 @Field(() => Boolean) @Column({ default: false }) verified: boolean;.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m not sure… but I got here looking for a solution and didn’t find one… without a lot of digging (maybe this is a documentation issue).
But
disableMixedMap
worked for me … applied to the above example might look something like this:As of now, one should do something like:
But I don’t think it’s ideal