storoge

Untitled

Mar 31st, 2017
497
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mongoObjectId = function () {
  2.     var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
  3.     return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
  4.         return (Math.random() * 16 | 0).toString(16);
  5.     }).toLowerCase();
  6. };
  7.  
  8. var source =  db.auto_proc.findOne({ "_id": ObjectId("58dd65a1a78edfeba6f59fb6")});
  9.  
  10. var mfc = [
  11. ["mfc-himki", "mfc_himki@mail.ru;it@mfchimki.ru;alex_@bk.ru"],
  12. ["mfc-lobnya", "prostakova@mfclobnya.ru;astepanov@mfclobnya.ru;adzuba@mfclobnya.ru;mfc.lobnya@yandex.ru"]
  13.  
  14.         ];
  15.        
  16. var new_auto_proc = source;
  17.  
  18. for (var i=0, len=mfc.length; i<len; i++) {
  19.      
  20.      
  21.      new_auto_proc._id = mongoObjectId();
  22.      new_auto_proc.name = "eTicketStage"+"_"+ mfc[i][0];
  23.      new_auto_proc.handlers[0].emails[0] = mfc[i][1];
  24.      new_auto_proc.parameters[0].value = mfc[i][0];
  25.      
  26.      db.auto_proc.save(new_auto_proc);
  27.      print("Saved auto_proc " + new_auto_proc.name );
  28.      //new_auto_proc.name = "xxx";
  29.      
  30. }
RAW Paste Data