M
Manifest•7d ago
witek

No relations in findOneById

Hi folks! I'm not sure if it's a bug or if I miss something. I'm trying to get related items to delete them before deleting the main one. Here is my yaml config:
name: emka
entities:
Project:
properties:
- name: title
type: string
Image:
properties:
- {
name: photo,
type: image,
options: { sizes: { small: { width: 256 }, large: { width: 1024 } } },
}
- name: order
type: number
belongsTo:
- Project
name: emka
entities:
Project:
properties:
- name: title
type: string
Image:
properties:
- {
name: photo,
type: image,
options: { sizes: { small: { width: 256 }, large: { width: 1024 } } },
}
- name: order
type: number
belongsTo:
- Project
And here is a code I use to get a Project with related images:
const project = await manifest
.from('projects')
.with(['images'])
.findOneById(projectIdNum);
const project = await manifest
.from('projects')
.with(['images'])
.findOneById(projectIdNum);
where projectIdNum = 1 But the returned object looks like that:
{ id: 1, title: 'test' }
{ id: 1, title: 'test' }
There are no images and I'm sure that there are ones. Database:
1|2025-04-11 17:25:27|2025-04-11 17:25:27|{"small":"http://localhost:1111/storage/images/photo/Apr2025/d6dx21yinm9d25g6m-small.jpg","large":"http://localhost:1111/storage/images/photo/Apr2025/d6dx21yinm9d25g6m-large.jpg"}|1|
2|2025-04-11 17:25:58|2025-04-11 17:25:58|{"small":"http://localhost:1111/storage/images/photo/Apr2025/d6dx21yinm9d2631j-small.jpg","large":"http://localhost:1111/storage/images/photo/Apr2025/d6dx21yinm9d2631j-large.jpg"}|1|
1|2025-04-11 17:25:27|2025-04-11 17:25:27|{"small":"http://localhost:1111/storage/images/photo/Apr2025/d6dx21yinm9d25g6m-small.jpg","large":"http://localhost:1111/storage/images/photo/Apr2025/d6dx21yinm9d25g6m-large.jpg"}|1|
2|2025-04-11 17:25:58|2025-04-11 17:25:58|{"small":"http://localhost:1111/storage/images/photo/Apr2025/d6dx21yinm9d2631j-small.jpg","large":"http://localhost:1111/storage/images/photo/Apr2025/d6dx21yinm9d2631j-large.jpg"}|1|
Am I doing something wrong? Best regards
3 Replies
witek
witekOP•7d ago
For now I just use a workaround like that
const images = await manifest.from('images').with(['project'])
.where('project.id = ' + projectIdNum).find();
const images = await manifest.from('images').with(['project'])
.where('project.id = ' + projectIdNum).find();
brunobuddy
brunobuddy•6d ago
@witek thank you so much for reporting this issue. Indeed it was a bug on findOnById(): the relations were not loaded. We fixed it, please update your @mnfst/sdk to version 1.2.1 ! Cheers 🙂
witek
witekOP•6d ago
Great, thanks for fix and info.

Did you find this page helpful?