I have array like this :
"organizationIds" : [
ObjectId("60373852f64bf2cc8c73136d"),
ObjectId("60373852f64bf2cc8c73139d"),
ObjectId("60373852f64bf2cc8c73138d")
]
I would like to this turn to object:
"organization":{
"ObjectId("60373852f64bf2cc8c73136d")":{
owner: false
},
"ObjectId("60373852f64bf2cc8c73138d")":{
owner: false
}
"ObjectId("60373852f64bf2cc8c73138d")":{
owner: true
}
}
I have tried using:
db.getCollection('users').aggregate([{$addFields:{organizationsPermissions:{$arrayToObject:"$organizationIds"}}},])
but I keep getting error"Unrecognised input type format for $arrayToObject: objectId".
Is there a way to reach my wanted result?