Skip to content

Instantly share code, notes, and snippets.

@nguyenhuucam91
Last active March 12, 2021 03:45
Show Gist options
  • Save nguyenhuucam91/c36ba6f6b01b22c572c42d4566d8ad41 to your computer and use it in GitHub Desktop.
Save nguyenhuucam91/c36ba6f6b01b22c572c42d4566d8ad41 to your computer and use it in GitHub Desktop.
Mongo git terminal
use petshops;
(function() {
var names = [
'Yolanda',
'Iska',
'Malone',
'Frank',
'Foxton',
'Pirate',
'Poppelhoffen',
'Elbow',
'Fluffy',
'Paphat'
]
var randName = function() {
var n = names.length;
return [
names[Math.floor(Math.random() * n)],
names[Math.floor(Math.random() * n)]
].join(' ');
}
var randAge = function(n) {
return Math.floor(Math.random() * n);
}
for (var i = 0; i < 1000; ++i) {
var person = {
name: randName(),
age: randAge(100)
}
if (Math.random() > 0.8) {
person.cat = {
name: randName(),
age: randAge(18)
}
}
db.people.insertOne(person);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment