documentation icon indicating copy to clipboard operation
documentation copied to clipboard

DOCS: EntintyService `findMany` returns Entry (not Entry[]) for singular types

Open abaksha-sc opened this issue 9 months ago • 1 comments

Link to the documentation page or resource

https://docs.strapi.io/dev-docs/api/entity-service/crud#findmany

Describe the bug

It was surprise for me that await strapi.entityService.findMany('api::some-uid') returns the object, but not an array for a singular types. And even docs says the return type Entry[]

Suggested improvements or fixes

Would be great to describe an exclusion note like For singular types "findMany" returns the entry data instead of array of entries.
Or even better to allow use findOne without id parameter for singular types, because it's strange that findMany doesn't return "many" entries. But it's another discussion...

Related issue(s)/PR(s)

No response

abaksha-sc avatar May 02 '24 15:05 abaksha-sc

Thanks for reporting, @abaksha-sc. We'll improve the docs.

By the way, in the upcoming Strapi 5, the Document Service API, which replaces the Entity Service API, will finally get consistent with this behavior and will always return an array (more details in the Entity Service to Document Service API migration: https://docs-next.strapi.io/dev-docs/migration/v4-to-v5/guides/from-entity-service-to-document-service, see note at the bottom of the page).

pwizla avatar May 03 '24 13:05 pwizla

Fixed in https://github.com/strapi/documentation/commit/c138cfd8081926357cda5af9bc36ea3e9b61be41

pwizla avatar May 21 '24 13:05 pwizla