Split string into an array of substrings or characters in MongoDB

后端 未结 4 1716
我在风中等你
我在风中等你 2020-12-16 05:22

I need to convert fields like this:

{ 
    \"_id\" : ObjectId(\"576fd6e87d33ed2f37a6d526\"), 
    \"phoneme\" : \"JH OY1 N Z\" 
}

into an a

4条回答
  •  难免孤独
    2020-12-16 06:12

    Much easier than I thought. Just use JavaScript split function. boom!

    db.temp.find().snapshot().forEach( function (el) {
    el.phonemes = el.phoneme.split(' ');
    db.temp.save(el);
    });
    

提交回复
热议问题