@@ -120,9 +120,38 @@ module.exports = ({ strapi }) => ({
120120 return entriesSum
121121 } ,
122122
123+ /**
124+ * Find an entry of a given content type.
125+ * More information: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/entity-service/crud.html#findone
126+ *
127+ * @param {object } options
128+ * @param {string } [options.id] - Id of the entry.
129+ * @param {string | string[] } [options.fields] - Fields present in the returned entry.
130+ * @param {object } [options.populate] - Relations, components and dynamic zones to populate.
131+ * @param {string } [options.contentType] - Content type.
132+ *
133+ * @returns {Promise<object> } - Entries.
134+ */
135+ async getEntry ( { contentType, id, fields = '*' , populate = '*' } ) {
136+ const contentTypeUid = this . getContentTypeUid ( { contentType } )
137+ if ( contentTypeUid === undefined ) return { }
138+
139+ const entry = await strapi . entityService . findOne ( contentTypeUid , id , {
140+ fields,
141+ populate,
142+ } )
143+
144+ if ( entry == null ) {
145+ strapi . log . error ( `Could not find entry with id ${ id } in ${ contentType } ` )
146+ }
147+
148+ return entry
149+ } ,
150+
123151 /**
124152 * Returns a batch of entries of a given content type.
125153 * More information: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/entity-service/crud.html#findmany
154+ *
126155 * @param {object } options
127156 * @param {string | string[] } [options.fields] - Fields present in the returned entry.
128157 * @param {number } [options.start] - Pagination start.
@@ -135,7 +164,7 @@ module.exports = ({ strapi }) => ({
135164 *
136165 * @returns {Promise<object[]> } - Entries.
137166 */
138- async getContentTypeEntries ( {
167+ async getEntries ( {
139168 contentType,
140169 fields = '*' ,
141170 start = 0 ,
@@ -182,7 +211,7 @@ module.exports = ({ strapi }) => ({
182211 const cbResponse = [ ]
183212 for ( let index = 0 ; index <= entries_count ; index += BATCH_SIZE ) {
184213 const entries =
185- ( await this . getContentTypeEntries ( {
214+ ( await this . getEntries ( {
186215 start : index ,
187216 limit : BATCH_SIZE ,
188217 contentType,
0 commit comments