I need to convert fields like this:
{
"_id" : ObjectId("576fd6e87d33ed2f37a6d526"),
"phoneme" : "JH OY1 N Z"
}
into an arrays of substrings like this
{
"_id" : ObjectId("576fd6e87d33ed2f37a6d526"),
"phonemes" : [ "JH", "OY1", "N", "Z" ]
}
and sometimes into an array of characters like this
{
"_id" : ObjectId("576fd6e87d33ed2f37a6d526"),
"phonemes" : ["J", "H", " ", "O", "Y", "1", " ", "N", " ", "Z"]
}
I found some code here which converts a string into an array, but it's a bit too simple for my purposes as there is only a single array element to be created.
db.members.find().snapshot().forEach( function (x) {
x.photos = [{"uri": "/images/" + x.photos}];
db.members.save(x);
});
Is the entire javascript language available to me from within mongo shell statements?