witek
witek
MManifest
Created by witek on 4/14/2025 in #questions-🙋
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
4 replies