Skip to content

Commit 05e6052

Browse files
refactor: extract query options into separate variable for cleaner code
Simplify strapi.documents().findOne() call by extracting query parameters into a queryOptions object
1 parent 674e998 commit 05e6052

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

server/src/services/content-types/content-types.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,11 @@ export default ({ strapi }) => ({
158158
status = 'published',
159159
locale,
160160
} = entriesQuery
161+
const queryOptions = { documentId, fields, populate, status, locale }
161162
const contentTypeUid = this.getContentTypeUid({ contentType })
162163
if (contentTypeUid === undefined) return {}
163164

164-
const entry = await strapi.documents(contentTypeUid).findOne({
165-
documentId,
166-
fields,
167-
populate,
168-
status,
169-
locale,
170-
})
165+
const entry = await strapi.documents(contentTypeUid).findOne(queryOptions)
171166

172167
if (entry == null) {
173168
strapi.log.error(

0 commit comments

Comments
 (0)