I want to split a string into array of letters just like we do in javascript, Eg,
let x = "String";
x.split('') // ['S', 't', 'r', 'i', 'n', 'g']
But, if I do the same using $split in aggregation pipeline, like below,
{
$project:{
_id:"$_id._id",
name:"$_id.name",
array_field:{ $split: ["$_id.name", ""] }
}
}
its throwing me error like this,
{
"message" : "PlanExecutor error during aggregation :: caused by :: $split requires a non-empty separator",
"ok" : 0,
"code" : 40087,
"codeName" : "Location40087",
"name" : "MongoError"
}
can anyone help me out with this problem. thanks.