Answer the question
In order to leave comments, you need to log in
Mongo - how to rename object keys?
I have a selection of objects
var pages = db.getCollection('blocks_copy')
.find({Type: 'page', Folder: {$in : ['bakeries/rosenborg/pages', 'bakeries/brogylen/pages']}, 'blocks': { $exists: true }}).toArray()
printjson(pages)
pages.forEach(function(e){
var changedNames = Object.keys(e.blocks).map(function(e){return `Rosenborg${e}`})
printjson(changedNames)
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question