Last active
August 29, 2015 14:08
-
-
Save andreabalducci/5a8c1870f7b4b3213345 to your computer and use it in GitHub Desktop.
mongodb halloween party
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.halloween.drop() | |
tags = []; | |
[1,2,3,4].forEach(function(num){ | |
tags.push(''+num); | |
db.halloween.insert({ | |
num: NumberInt(num), | |
tags:tags | |
}) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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