I have this pipeline:
[
{"$lookup": {
"from": "base_model",
"localField": "suboptions",
"foreignField": "_id",
"as": "suboptions"
}},
{"$project": {"name": "$name",
"uuid": "$uuid",
"is_required": "$is_required",
"is_suboption": "$is_subption",
"suboptions": "$suboptions",
"option_uuid": "$option_uuid",
"is_in_stock": "$is_in_stock",
"created_at": "$created_at",
"updated_at": "$updated_at",
"_id": 0,
}},
{"$addFields": {
"suboptions.id": {"$toString": "$suboptions._id"}
}},
{"$project": {
"suboptions._id": 0,
}}
]
If I remove the $addFields stage it works fine, but I need to get the result in JSON serializable format, so I need to change the type of _id field in suboptions to string, but this is returning Unsupported conversion from array to string in $convert with no onError value.
How can I fix this?