diff --git a/docs/3.0.0-beta.x/concepts/queries.md b/docs/3.0.0-beta.x/concepts/queries.md index cf86966689..36b7ffd770 100644 --- a/docs/3.0.0-beta.x/concepts/queries.md +++ b/docs/3.0.0-beta.x/concepts/queries.md @@ -4,7 +4,7 @@ Strapi provides a utility function `strapi.query` to make database queries. You can just call `strapi.query('modelName', 'pluginName')` to access the query API for any model. -These queries handle for you specific Strapi features like `groups`, `filters` and `search`. +These queries handle for you specific Strapi features like `components`, `dynamic zones`, `filters` and `search`. ## API Reference @@ -97,7 +97,20 @@ Creates an entry in the database and returns the entry. ```js strapi.query('restaurant').create({ name: 'restaurant name', - // this is a group field. the order is persisted in db. + // this is a dynamiczone field. the order is persisted in db. + content: [ + { + __component: 'blog.rich-text', + title: 'some title', + subTitle: 'some sub title', + }, + { + __component: 'blog.quote', + quote: 'Some interesting quote', + author: 1, + }, + ], + // this is a component field. the order is persisted in db. opening_hours: [ { day_interval: 'Mon', @@ -134,6 +147,18 @@ strapi.query('restaurant').update( { id: 1 }, { name: 'restaurant name', + content: [ + { + __component: 'blog.rich-text', + title: 'some title', + subTitle: 'some sub title', + }, + { + __component: 'blog.quote', + quote: 'Some interesting quote', + author: 1, + }, + ], opening_hours: [ { day_interval: 'Mon', @@ -154,15 +179,29 @@ strapi.query('restaurant').update( ); ``` -When updating an entry with its groups beware that if you send the groups without any `id` the previous groups will be deleted and replaced. You can update the groups by sending their `id` with the rest of the fields: +When updating an entry with its components or dynamiczones beware that if you send the components without any `id` the previous components will be deleted and replaced. You can update the components by sending their `id` with the rest of the fields: -**Update by id and update previous groups** +**Update by id and update previous components** ```js strapi.query('restaurant').update( { id: 1 }, { name: 'Mytitle', + content: [ + { + __component: 'blog.rich-text', + id: 1, + title: 'some title', + subTitle: 'some sub title', + }, + { + __component: 'blog.quote', + id: 1, + quote: 'Some interesting quote', + author: 1, + }, + ], opening_hours: [ { id: 2, diff --git a/docs/3.0.0-beta.x/content-api/api-endpoints.md b/docs/3.0.0-beta.x/content-api/api-endpoints.md index 67c684292b..3bb5510fb8 100644 --- a/docs/3.0.0-beta.x/content-api/api-endpoints.md +++ b/docs/3.0.0-beta.x/content-api/api-endpoints.md @@ -2,25 +2,36 @@ When you create a `Content Type` you will have a certain number of **REST API endpoints** available to interact with it. -As an **example** let's consider the `Restaurant` as a **Content Type** and `Openning_hours` as a **Group** for the next steps. +As an **example** let's consider the following models: + +**Content Type**: + +- `Restaurant` + +**Components**: + +- `Openning hours` (category: `restaurant`) +- `Title With Subtitle` (category: `content`) +- `Image With Description` (category: `content`) :::: tabs -::: tab "Content Type" +::: tab "Content Types" ### `Restaurant` Content Type -| Fields | Type | Description | Options | -| :------------ | :----- | :------------------------------- | :----------- | -| name | string | Restaurant's title | | -| cover | media | Restaurant's cover image | | -| opening_hours | group | Restaurant's opening hours group | `repeatable` | +| Fields | Type | Description | Options | +| :------------ | :---------- | :----------------------------------- | :----------- | +| name | string | Restaurant's title | | +| cover | media | Restaurant's cover image | | +| content | dynamiczone | The restaurant profile content | | +| opening_hours | component | Restaurant's opening hours component | `repeatable` | ::: -::: tab Group +::: tab Components -### `Opening_hours` Group +### `Opening hours` Component | Fields | Type | Description | | :----------- | :----- | :------------------ | @@ -28,6 +39,25 @@ As an **example** let's consider the `Restaurant` as a **Content Type** and `Ope | opening_hour | string | Meta's opening hour | | closing_hour | string | Meta's closing hour | +--- + +### `Image With Description` Component + +| Fields | Type | Description | +| :------- | :----- | :------------ | +| title | string | The title | +| subTitle | string | the sub title | + +--- + +### `ImageWithDescription` Component + +| Fields | Type | Description | +| :---------- | :----- | :------------------- | +| image | media | The image file | +| title | string | the image title | +| description | text | the image dscription | + ::: :::: @@ -195,8 +225,35 @@ GET http://localhost:1337/restaurants "cover": { "id": 1, "url": "/uploads/3d89ba92f762433bbb75bbbfd9c13974.png" - //... }, + "content": [ + { + "__component": "content.title-with-subtitle", + "id": 1, + "title": "Restaurant 1 title", + "subTitle": "Cozy restaurant in the valley" + }, + { + "__component": "content.image-with-description", + "id": 1, + "image": { + "id": 1, + "name": "image.png", + "hash": "123456712DHZAUD81UDZQDAZ", + "sha256": "v", + "ext": ".png", + "mime": "image/png", + "size": 122.95, + "url": "http://localhost:1337/uploads/123456712DHZAUD81UDZQDAZ.png", + "provider": "local", + "provider_metadata": null, + "created_at": "2019-12-09T00:00:00.000Z", + "updated_at": "2019-12-09T00:00:00.000Z" + }, + "title": "Amazing photography", + "description": "This is an amazing photography taken..." + } + ], "opening_hours": [ { "id": 1, @@ -204,7 +261,6 @@ GET http://localhost:1337/restaurants "opening_hour": "7:30 PM", "closing_hour": "10:00 PM" } - //... ] } ] @@ -229,8 +285,35 @@ GET http://localhost:1337/restaurants/1 "cover": { "id": 1, "url": "/uploads/3d89ba92f762433bbb75bbbfd9c13974.png" - //... }, + "content": [ + { + "__component": "content.title-with-subtitle", + "id": 1, + "title": "Restaurant 1 title", + "subTitle": "Cozy restaurant in the valley" + }, + { + "__component": "content.image-with-description", + "id": 1, + "image": { + "id": 1, + "name": "image.png", + "hash": "123456712DHZAUD81UDZQDAZ", + "sha256": "v", + "ext": ".png", + "mime": "image/png", + "size": 122.95, + "url": "http://localhost:1337/uploads/123456712DHZAUD81UDZQDAZ.png", + "provider": "local", + "provider_metadata": null, + "created_at": "2019-12-09T00:00:00.000Z", + "updated_at": "2019-12-09T00:00:00.000Z" + }, + "title": "Amazing photography", + "description": "This is an amazing photography taken..." + } + ], "opening_hours": [ { "id": 1, @@ -272,6 +355,19 @@ POST http://localhost:1337/restaurants { "title": "Restaurant 1", "cover": 1, + "content": [ + { + "__component": "content.title-with-subtitle", + "title": "Restaurant 1 title", + "subTitle": "Cozy restaurant in the valley" + }, + { + "__component": "content.image-with-description", + "image": 1, // user form data to upload the file or an id to reference an exisiting image + "title": "Amazing photography", + "description": "This is an amazing photography taken..." + } + ], "opening_hours": [ { "day_interval": "Tue - Sat", @@ -291,8 +387,35 @@ POST http://localhost:1337/restaurants "cover": { "id": 1, "url": "/uploads/3d89ba92f762433bbb75bbbfd9c13974.png" - //... }, + "content": [ + { + "__component": "content.title-with-subtitle", + "id": 1, + "title": "Restaurant 1 title", + "subTitle": "Cozy restaurant in the valley" + }, + { + "__component": "content.image-with-description", + "id": 1, + "image": { + "id": 1, + "name": "image.png", + "hash": "123456712DHZAUD81UDZQDAZ", + "sha256": "v", + "ext": ".png", + "mime": "image/png", + "size": 122.95, + "url": "http://localhost:1337/uploads/123456712DHZAUD81UDZQDAZ.png", + "provider": "local", + "provider_metadata": null, + "created_at": "2019-12-09T00:00:00.000Z", + "updated_at": "2019-12-09T00:00:00.000Z" + }, + "title": "Amazing photography", + "description": "This is an amazing photography taken..." + } + ], "opening_hours": [ { "id": 1, @@ -318,6 +441,21 @@ PUT http://localhost:1337/restaurants/1 ```json { "title": "Restaurant 1", + "content": [ + { + "__component": "content.title-with-subtitle", + // editing one of the previous item by passing its id + "id": 2, + "title": "Restaurant 1 title", + "subTitle": "Cozy restaurant in the valley" + }, + { + "__component": "content.image-with-description", + "image": 1, // user form data to upload the file or an id to reference an exisiting image + "title": "Amazing photography", + "description": "This is an amazing photography taken..." + } + ], "opening_hours": [ { // adding a new item @@ -345,8 +483,35 @@ PUT http://localhost:1337/restaurants/1 "cover": { "id": 1, "url": "/uploads/3d89ba92f762433bbb75bbbfd9c13974.png" - //... }, + "content": [ + { + "__component": "content.title-with-subtitle", + "id": 1, + "title": "Restaurant 1 title", + "subTitle": "Cozy restaurant in the valley" + }, + { + "__component": "content.image-with-description", + "id": 2, + "image": { + "id": 1, + "name": "image.png", + "hash": "123456712DHZAUD81UDZQDAZ", + "sha256": "v", + "ext": ".png", + "mime": "image/png", + "size": 122.95, + "url": "http://localhost:1337/uploads/123456712DHZAUD81UDZQDAZ.png", + "provider": "local", + "provider_metadata": null, + "created_at": "2019-12-09T00:00:00.000Z", + "updated_at": "2019-12-09T00:00:00.000Z" + }, + "title": "Amazing photography", + "description": "This is an amazing photography taken..." + } + ], "opening_hours": [ { "id": 1, @@ -383,8 +548,35 @@ DELETE http://localhost:1337/restaurants/1 "cover": { "id": 1, "url": "/uploads/3d89ba92f762433bbb75bbbfd9c13974.png" - //... }, + "content": [ + { + "__component": "content.title-with-subtitle", + "id": 1, + "title": "Restaurant 1 title", + "subTitle": "Cozy restaurant in the valley" + }, + { + "__component": "content.image-with-description", + "id": 2, + "image": { + "id": 1, + "name": "image.png", + "hash": "123456712DHZAUD81UDZQDAZ", + "sha256": "v", + "ext": ".png", + "mime": "image/png", + "size": 122.95, + "url": "http://localhost:1337/uploads/123456712DHZAUD81UDZQDAZ.png", + "provider": "local", + "provider_metadata": null, + "created_at": "2019-12-09T00:00:00.000Z", + "updated_at": "2019-12-09T00:00:00.000Z" + }, + "title": "Amazing photography", + "description": "This is an amazing photography taken..." + } + ], "opening_hours": [ { "id": 1, diff --git a/docs/3.0.0-beta.x/plugins/upload.md b/docs/3.0.0-beta.x/plugins/upload.md index 2cd257ee06..fb3dd2be16 100644 --- a/docs/3.0.0-beta.x/plugins/upload.md +++ b/docs/3.0.0-beta.x/plugins/upload.md @@ -213,8 +213,8 @@ And for your files, they have to be prefixed by `files`. Example here with cover attribute `files.cover`. ::: tip -If you want to upload files for a group, you will have to specify the inidex of the item you wan to add the file. -Example `files.my_group_name[the_index].attribute_name` +If you want to upload files for a component, you will have to specify the inidex of the item you wan to add the file. +Example `files.my_component_name[the_index].attribute_name` ::: ::: warning