feat: include document relation
This commit is contained in:
parent
65d7b5a07f
commit
dd2128609d
1 changed files with 4 additions and 2 deletions
|
|
@ -178,6 +178,7 @@ export class ProductController extends Controller {
|
|||
const [result, total] = await prisma.$transaction([
|
||||
prisma.product.findMany({
|
||||
include: {
|
||||
document: true,
|
||||
createdBy: true,
|
||||
updatedBy: true,
|
||||
},
|
||||
|
|
@ -190,7 +191,7 @@ export class ProductController extends Controller {
|
|||
]);
|
||||
|
||||
return {
|
||||
result,
|
||||
result: result.map((v) => ({ ...v, document: v.document.map((doc) => doc.name) })),
|
||||
page,
|
||||
pageSize,
|
||||
total,
|
||||
|
|
@ -202,6 +203,7 @@ export class ProductController extends Controller {
|
|||
async getProductById(@Path() productId: string) {
|
||||
const record = await prisma.product.findFirst({
|
||||
include: {
|
||||
document: true,
|
||||
createdBy: true,
|
||||
updatedBy: true,
|
||||
},
|
||||
|
|
@ -210,7 +212,7 @@ export class ProductController extends Controller {
|
|||
|
||||
if (!record) throw notFoundError("Product");
|
||||
|
||||
return record;
|
||||
return { ...record, document: record.document.map((doc) => doc.name) };
|
||||
}
|
||||
|
||||
@Post()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue