Mongoose query with unprojection on dynamic zone field causes error #6016
Labels
good first issue
Good for newcomers
issue: bug
Issue reporting a bug
severity: medium
If it breaks the basic use of the product but can be worked around
source: core:strapi
Source is core/strapi package
status: confirmed
Confirmed by a Strapi Team member or multiple community members
Describe the bug
When creating a custom controller on a content type that has a dynamic zone field, excluding it from the selection of the query causes an error (Mongoose). For instance lets say we have dynamic zone field called "modules".
If my query looks like this:
Then it causes an error with the strapi-mongoose-connector library. If I don't include "modules" in it, it works. If I try to unproject another field that is not a dynamic zone field, it works.
My custom controller code looks like this:
The error message I get is in this screen shot:
It appears that the library is still trying to map on the dynamic zone field despite it not being in the returned query.
Expected behavior
It should return all objects that match the query of the controller without the "modules" dynamic zone field.
System
Thanks again and as always I appreciate the work the Strapi team does!
The text was updated successfully, but these errors were encountered: