ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • javascript를 이용한 1MB 짜리 document insert 하기
    NoSQL/MongoDB 2012. 9. 6. 12:26

    안녕하세요. 이스트럭(강동운) 입니다.


    오늘은 javascript를 이용해서 mongodb에 1MB 정도 되는 document를 insert 하는 쿼리 입니다.


    소스 바로 보시죵~~!

    var buf = new Array();
    var str = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01123456789012345678901234";
    for(var i=0;i<1024;i++){buf[i] = str;}
    var garbage_data = buf.join("");
    
    
    people = ["Marc", "Bill", "George", "Eliot", "Matt", "Trey", "Tracy", "Greg", "Steve", "Kristina", "Katie", "Jeff"];
    
    for(var i=0; i<5000; i++){
         name = people[Math.floor(Math.random()*people.length)];
         user_id = i + 10000;
         boolean = [true, false][Math.floor(Math.random()*2)];
         added_at = new Date();
         number = Math.floor(Math.random()*10001);
         db.member.save({"name":name, "user_id":user_id, "boolean": boolean, "added_at":added_at, "number":number, "garbage_data": garbage_data });
    }
    
    

    결과화면





    감사합니다 ^^


    작성일: 2012-09-06

    작성자: 이스트럭(강동운)


Designed by Tistory.