Last active
March 12, 2021 03:45
-
-
Save nguyenhuucam91/c36ba6f6b01b22c572c42d4566d8ad41 to your computer and use it in GitHub Desktop.
Mongo git terminal
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
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