Skip to content

Instantly share code, notes, and snippets.

@andreabalducci
Last active August 29, 2015 14:08
Show Gist options
  • Save andreabalducci/5a8c1870f7b4b3213345 to your computer and use it in GitHub Desktop.
Save andreabalducci/5a8c1870f7b4b3213345 to your computer and use it in GitHub Desktop.
mongodb halloween party
db.halloween.drop()
tags = [];
[1,2,3,4].forEach(function(num){
tags.push(''+num);
db.halloween.insert({
num: NumberInt(num),
tags:tags
})
})
function changeState(doc){
doc.buffer = doc.buffer || []
doc.buffer.push(Array.apply(null, Array(4096)).map(function() {
return {
text_1 : '01234567890', text_2 : 'qwertyuiop',
text_3 : 'asdfghjkl', text_4 : 'zxcvbnm',
}
}))
}
db.halloween.find().forEach(function(doc){
print('current document: ' + doc.num)
changeState(doc)
db.halloween.save(doc)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment