SHARE
TWEET

Untitled

a guest Oct 21st, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use people
  2. (function() {
  3.   var names = [
  4.     'Yolanda',
  5.     'Iska',
  6.     'Malone',
  7.     'Frank',
  8.     'Foxton',
  9.     'Pirate',
  10.     'Poppelhoffen',
  11.     'Elbow',
  12.     'Fluffy',
  13.     'Paphat'
  14.   ]
  15.   var randName = function() {
  16.     var n = names.length;
  17.     return [
  18.       names[Math.floor(Math.random() * n)],
  19.       names[Math.floor(Math.random() * n)]
  20.     ].join(' ');
  21.   }
  22.   var randAge = function(n) {
  23.     return Math.floor(Math.random() * n);
  24.   }
  25.   for (var i = 0; i < 1000; ++i) {
  26.     var person = {
  27.       name: randName(),
  28.       age: randAge(100)
  29.     }
  30.     if (Math.random() > 0.8) {
  31.       person.cat = {
  32.         name: randName(),
  33.         age: randAge(18)
  34.       }
  35.     }
  36.     db.people.insert(person);
  37.   };
  38. })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top