Skip to content

Commit 6c121fa

Browse files
committed
fix: update category relations
1 parent a45a1d1 commit 6c121fa

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

src/api/category/content-types/category/schema.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,31 @@
4343
"type": "string"
4444
},
4545
"image": {
46+
"type": "media",
47+
"multiple": false,
48+
"required": false,
4649
"allowedTypes": [
4750
"images",
4851
"files",
4952
"videos",
5053
"audios"
5154
],
52-
"type": "media",
53-
"multiple": false,
5455
"pluginOptions": {
5556
"i18n": {
5657
"localized": true
5758
}
5859
}
60+
},
61+
"subcategories": {
62+
"type": "relation",
63+
"relation": "oneToMany",
64+
"target": "api::subcategory.subcategory"
65+
},
66+
"subcategory": {
67+
"type": "relation",
68+
"relation": "oneToOne",
69+
"target": "api::subcategory.subcategory",
70+
"mappedBy": "category"
5971
}
6072
}
6173
}

src/api/subcategory/content-types/subcategory/schema.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"info": {
55
"singularName": "subcategory",
66
"pluralName": "subcategories",
7-
"displayName": "subcategories"
7+
"displayName": "subcategories",
8+
"description": ""
89
},
910
"options": {
1011
"draftAndPublish": true
@@ -16,20 +17,27 @@
1617
},
1718
"slug": {
1819
"type": "string",
19-
"unique": true
20+
"unique": false
2021
},
2122
"image": {
23+
"type": "media",
24+
"multiple": false,
25+
"required": false,
2226
"allowedTypes": [
2327
"images",
2428
"files",
2529
"videos",
2630
"audios"
27-
],
28-
"type": "media",
29-
"multiple": false
31+
]
3032
},
3133
"subtitle": {
3234
"type": "string"
35+
},
36+
"category": {
37+
"type": "relation",
38+
"relation": "oneToOne",
39+
"target": "api::category.category",
40+
"inversedBy": "subcategory"
3341
}
3442
}
3543
}

types/generated/contentTypes.d.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,14 @@ export interface ApiCategoryCategory extends Struct.CollectionTypeSchema {
415415
localized: false;
416416
};
417417
}>;
418+
subcategories: Schema.Attribute.Relation<
419+
'oneToMany',
420+
'api::subcategory.subcategory'
421+
>;
422+
subcategory: Schema.Attribute.Relation<
423+
'oneToOne',
424+
'api::subcategory.subcategory'
425+
>;
418426
subtitle: Schema.Attribute.String &
419427
Schema.Attribute.SetPluginOptions<{
420428
i18n: {
@@ -543,6 +551,7 @@ export interface ApiNavbarNavbar extends Struct.SingleTypeSchema {
543551
export interface ApiSubcategorySubcategory extends Struct.CollectionTypeSchema {
544552
collectionName: 'subcategories';
545553
info: {
554+
description: '';
546555
displayName: 'subcategories';
547556
pluralName: 'subcategories';
548557
singularName: 'subcategory';
@@ -551,6 +560,7 @@ export interface ApiSubcategorySubcategory extends Struct.CollectionTypeSchema {
551560
draftAndPublish: true;
552561
};
553562
attributes: {
563+
category: Schema.Attribute.Relation<'oneToOne', 'api::category.category'>;
554564
createdAt: Schema.Attribute.DateTime;
555565
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
556566
Schema.Attribute.Private;
@@ -563,7 +573,7 @@ export interface ApiSubcategorySubcategory extends Struct.CollectionTypeSchema {
563573
Schema.Attribute.Private;
564574
name: Schema.Attribute.String;
565575
publishedAt: Schema.Attribute.DateTime;
566-
slug: Schema.Attribute.String & Schema.Attribute.Unique;
576+
slug: Schema.Attribute.String;
567577
subtitle: Schema.Attribute.String;
568578
updatedAt: Schema.Attribute.DateTime;
569579
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &

0 commit comments

Comments
 (0)