Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ module.exports = {
await validate.contentAPI.query(ctx.query, contentType, { auth: ctx.state.auth });
const sanitizedQueryParams = await sanitize.contentAPI.query(ctx.query, contentType, { auth: ctx.state.auth });

const entities = await strapi.entityService.findMany(contentType.uid, sanitizedQueryParams);
const documents = await strapi.documents(contentType.uid).findMany(sanitizedQueryParams);

return await sanitize.contentAPI.output(entities, contentType, { auth: ctx.state.auth });
return await sanitize.contentAPI.output(documents, contentType, { auth: ctx.state.auth });
}
}
```
Expand All @@ -340,9 +340,9 @@ export default {
await validate.contentAPI.query(ctx.query, contentType, { auth: ctx.state.auth });
const sanitizedQueryParams = await sanitize.contentAPI.query(ctx.query, contentType, { auth: ctx.state.auth });

const entities = await strapi.entityService.findMany(contentType.uid, sanitizedQueryParams);
const documents = await strapi.documents(contentType.uid).findMany(sanitizedQueryParams);

return await sanitize.contentAPI.output(entities, contentType, { auth: ctx.state.auth });
return await sanitize.contentAPI.output(documents, contentType, { auth: ctx.state.auth });
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ Proper implementation largely depends on your project's needs and custom code, b
* the response includes author-related information
*/
if (entryId) {
entry = await strapi.entityService.findOne(
// highlight-start
// replace the next line with your proper content-type identifier
"api::restaurant.restaurant",
// highlight-end
entry = await strapi.documents('api::restaurant.restaurant').findOne(
entryId,
{ populate: "*" }
);
Expand Down
32 changes: 16 additions & 16 deletions docusaurus/docs/dev-docs/backend-customization/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ module.exports = createCoreService('api::restaurant.restaurant', ({ strapi }) =>
},

// Method 3: Replacing a core service
async findOne(entityId, params = {}) {
return strapi.entityService.findOne('api::restaurant.restaurant', entityId, this.getFetchParams(params));
async findOne(documentId, params = {}) {
return strapi.documents('api::restaurant.restaurant').findOne(documentId, this.getFetchParams(params));
}
}));
```
Expand Down Expand Up @@ -114,8 +114,8 @@ export default factories.createCoreService('api::restaurant.restaurant', ({ stra
},

// Method 3: Replacing a core service
async findOne(entityId, params = {}) {
return strapi.entityService.findOne('api::restaurant.restaurant', entityId, this.getFetchParams(params));
async findOne(documentId, params = {}) {
return strapi.documents('api::restaurant.restaurant').findOne(documentId, this.getFetchParams(params));
}
}));
```
Expand Down Expand Up @@ -299,9 +299,9 @@ async find(params) {
<TabItem value="find-one" label="findOne()">

```js
async findOne(entityId, params) {
async findOne(documentId, params) {
// some logic here
const result = await super.findOne(entityId, params);
const result = await super.findOne(documentId, params);
// some more logic

return result;
Expand All @@ -327,9 +327,9 @@ async create(params) {
<TabItem value="update" label="update()">

```js
async update(entityId, params) {
async update(documentId, params) {
// some logic here
const result = await super.update(entityId, params);
const result = await super.update(documentId, params);
// some more logic

return result;
Expand All @@ -341,9 +341,9 @@ async update(entityId, params) {
<TabItem value="delete" label="delete()">

```js
async delete(entityId, params) {
async delete(documentId, params) {
// some logic here
const result = await super.delete(entityId, params);
const result = await super.delete(documentId, params);
// some more logic

return result;
Expand All @@ -366,10 +366,10 @@ async delete(entityId, params) {
```js
async find(params) {
// some logic here
const entity = await super.find(params);
const document = await super.find(params);
// some more logic

return entity;
return document;
}
```

Expand All @@ -380,10 +380,10 @@ async find(params) {
```js
async createOrUpdate({ data, ...params }) {
// some logic here
const entity = await super.createOrUpdate({ data, ...params });
const document = await super.createOrUpdate({ data, ...params });
// some more logic

return entity;
return document;
}
```

Expand All @@ -394,10 +394,10 @@ async createOrUpdate({ data, ...params }) {
```js
async delete(params) {
// some logic here
const entity = await super.delete(params);
const document = await super.delete(params);
// some more logic

return entity;
return document;
}
```

Expand Down