Skip to content

Commit

Permalink
add category
Browse files Browse the repository at this point in the history
  • Loading branch information
nikaaru committed Aug 27, 2024
1 parent 4526374 commit 03d5750
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 28 deletions.
26 changes: 26 additions & 0 deletions src/api/category/content-types/category/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"kind": "collectionType",
"collectionName": "categories",
"info": {
"singularName": "category",
"pluralName": "categories",
"displayName": "Category"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"Name": {
"type": "string",
"required": true,
"unique": true
},
"restaurants": {
"type": "relation",
"relation": "manyToMany",
"target": "api::restaurant.restaurant",
"inversedBy": "categories"
}
}
}
7 changes: 7 additions & 0 deletions src/api/category/controllers/category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* category controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::category.category');
7 changes: 7 additions & 0 deletions src/api/category/routes/category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* category router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::category.category');
7 changes: 7 additions & 0 deletions src/api/category/services/category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* category service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::category.category');
6 changes: 6 additions & 0 deletions src/api/restaurant/content-types/restaurant/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
},
"Description": {
"type": "blocks"
},
"categories": {
"type": "relation",
"relation": "manyToMany",
"target": "api::category.category",
"mappedBy": "restaurants"
}
}
}
90 changes: 62 additions & 28 deletions types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
import type { Struct, Schema } from '@strapi/strapi';

export interface ApiRestaurantRestaurant extends Struct.CollectionTypeSchema {
collectionName: 'restaurants';
info: {
singularName: 'restaurant';
pluralName: 'restaurants';
displayName: 'Restaurant';
};
options: {
draftAndPublish: true;
};
attributes: {
Name: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.Unique &
Schema.Attribute.DefaultTo<'Name'>;
Description: Schema.Attribute.Blocks;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}

export interface PluginUploadFile extends Struct.CollectionTypeSchema {
collectionName: 'files';
info: {
Expand Down Expand Up @@ -472,6 +445,66 @@ export interface PluginUsersPermissionsUser
};
}

export interface ApiCategoryCategory extends Struct.CollectionTypeSchema {
collectionName: 'categories';
info: {
singularName: 'category';
pluralName: 'categories';
displayName: 'Category';
};
options: {
draftAndPublish: true;
};
attributes: {
Name: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.Unique;
restaurants: Schema.Attribute.Relation<
'manyToMany',
'api::restaurant.restaurant'
>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}

export interface ApiRestaurantRestaurant extends Struct.CollectionTypeSchema {
collectionName: 'restaurants';
info: {
singularName: 'restaurant';
pluralName: 'restaurants';
displayName: 'Restaurant';
};
options: {
draftAndPublish: true;
};
attributes: {
Name: Schema.Attribute.String &
Schema.Attribute.Required &
Schema.Attribute.Unique &
Schema.Attribute.DefaultTo<'Name'>;
Description: Schema.Attribute.Blocks;
categories: Schema.Attribute.Relation<
'manyToMany',
'api::category.category'
>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
};
}

export interface AdminPermission extends Struct.CollectionTypeSchema {
collectionName: 'admin_permissions';
info: {
Expand Down Expand Up @@ -821,7 +854,6 @@ export interface AdminTransferTokenPermission
declare module '@strapi/strapi' {
export module Public {
export interface ContentTypeSchemas {
'api::restaurant.restaurant': ApiRestaurantRestaurant;
'plugin::upload.file': PluginUploadFile;
'plugin::upload.folder': PluginUploadFolder;
'plugin::i18n.locale': PluginI18NLocale;
Expand All @@ -832,6 +864,8 @@ declare module '@strapi/strapi' {
'plugin::users-permissions.permission': PluginUsersPermissionsPermission;
'plugin::users-permissions.role': PluginUsersPermissionsRole;
'plugin::users-permissions.user': PluginUsersPermissionsUser;
'api::category.category': ApiCategoryCategory;
'api::restaurant.restaurant': ApiRestaurantRestaurant;
'admin::permission': AdminPermission;
'admin::user': AdminUser;
'admin::role': AdminRole;
Expand Down

0 comments on commit 03d5750

Please sign in to comment.