This file contains 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
count_by = function(collection,field) { | |
return collection.aggregate({ | |
$group: { | |
_id: "$" + field, | |
count: { $sum: 1 } | |
} | |
}) | |
} | |
count_by(db.vid10,'char'); |
This file contains 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
[alias] | |
lgb = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches |
This file contains 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 add_rand_field(collection) { | |
collection.find().forEach(function(data) { | |
collection.update({_id:data._id}, { | |
$set:{rand:Math.random()} | |
}); | |
}); | |
collection.ensureIndex({rand:1},{background:true}) | |
} |