Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
abaksha-sc opened this issue May 2, 2024 · 2 comments
Assignees

Comments

@abaksha-sc
Copy link

abaksha-sc commented May 2, 2024

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

@pwizla
Copy link
Collaborator

pwizla commented May 3, 2024

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
Copy link
Collaborator

pwizla commented May 21, 2024

Fixed in c138cfd

@pwizla pwizla closed this as completed May 21, 2024
@pwizla pwizla self-assigned this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants