Replies: 2 comments
-
Hey @devj3ns, thank you for the report! One thing that you could do is to have I'm converting this to a discussion, let me know if you don't agree with that. |
Beta Was this translation helpful? Give feedback.
-
Hey @r1tsuu, thanks for the investigation and explanation, it makes sense! I resolved the issue by adding two hooks that handle data transformation when it's undefined: hooks: {
beforeChange: [({ value }) => (!value ? [0, 0] : value)],
afterRead: [({ value }) => !value || (Array.isArray(value) && value[0] === 0 && value[1] === 0) ? null : value],
}, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the Bug
When defining a collection with a point field inside an array, a
MongoServerError
occurs during document saving. This error only appears when the array contains at least one filled point field and one empty point field. The error does not occur if all point fields are either empty or all are filled.It appears the issue arises when attempting to save an empty point field ({}), as MongoDB cannot properly interpret it as a valid GeoJSON type. The error message is as follows:
Link to the code that reproduces this issue
https://github.com/devj3ns/payload-mongodb-point-field-bug
Reproduction Steps
Which area(s) are affected? (Select all that apply)
db-mongodb, area: core
Environment Info
Beta Was this translation helpful? Give feedback.
All reactions