Gustavo is correct about the two types issue, but the solution depends on your use case and the data you're interested in.
In my case I have documents with a config field that can be either an object or null:
{ config: null }
{ config: { token: "abc123", date: "2023-05-24T08:25:19" }}
When I export in Compass and it asks me to select fields, I get 3 options:
- config
- config.token
- config.date
By having the root field and the sub-fields selected, there is an overlap in the fields that are exported, hence the path collision issue. To resolve this, you can either deselect config
or only select config
.
If you deselect config
(i.e. just select the sub-fields), then the output documents will only contain the config
field if there is data for the sub-fields. In any documents where config
is null, the config
field is omitted.
If you only select config
(i.e. deselect the sub-fields) then the output will contain the config
field regardless of whether it is null or an object. It will still be omitted if it is undefined.