Hi !
I'm pretty new with mongo and Metabase. I've done a native query that works great in Mongo Chart. But when I'm creating a native question with the same query I have this error :
readStartArray can only be called when CurrentBSONType is ARRAY, not when CurrentBSONType is DOCUMENT
I've tried to find a solution online for ages but nothing helped me.
Here is my query extracted from MongoDB Chart :
{
"isFetching": false,
"isOpen": true,
"pipeline": [
{
"$lookup": {
"from": "interests",
"localField": "interest",
"foreignField": "_id",
"as": "interest_lookup_interests"
}
},
{
"$addFields": {
"interest_lookup_interests": {
"$ifNull": [
{
"$arrayElemAt": [
"$interest_lookup_interests",
0
]
},
null
]
}
}
},
{
"$group": {
"_id": {
"__alias_0": "$interest_lookup_interests.name"
},
"__alias_1": {
"$sum": {
"$cond": [
{
"$ne": [
{
"$type": "$createdAt"
},
"missing"
]
},
1,
0
]
}
}
}
},
{
"$project": {
"_id": 0,
"__alias_0": "$_id.__alias_0",
"__alias_1": 1
}
},
{
"$project": {
"value": "$__alias_1",
"label": "$__alias_0",
"_id": 0
}
},
{
"$addFields": {
"__agg_sum": {
"$sum": [
"$value"
]
}
}
},
{
"$sort": {
"__agg_sum": -1
}
},
{
"$project": {
"__agg_sum": 0
}
},
{
"$limit": 5000
}
]
}