Last active
August 29, 2015 14:16
-
-
Save ppillip/85f4d59d98e6d398b975 to your computer and use it in GitHub Desktop.
batch.js
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
/* | |
내피시에 자바스크립트가 로딩이됩니다. | |
아래 파일은 array 계의 jQuery 인 underscore.js 라이브러리 입니다. | |
*/ | |
load("/Users/ppillip/scripts/underscore.js"); | |
/* | |
원하는 디비로 이동합니다. | |
*/ | |
use cys | |
/* | |
질의를 날려요. aggregation 입니다. | |
*/ | |
print('질의시작'); | |
var x = db.CYSNET_a_1.aggregate([ | |
{ | |
$match : { | |
C_CONTENT1_ARRAY:{$exists:true} | |
,$and : [ | |
{ CSDATE : { $gt : '20020225'} } | |
,{ CSDATE : { $lt : '20040410'} } | |
] | |
} | |
}, | |
{ | |
$unwind : '$C_CONTENT1_ARRAY' | |
}, | |
{ | |
$project : { | |
count : "$C_CONTENT1_ARRAY.c" | |
,word : "$C_CONTENT1_ARRAY.w" | |
} | |
}, | |
{ | |
$group : { | |
_id : '$word' | |
,count : { $sum : '$count'} | |
} | |
}, | |
{ | |
$match : { | |
_id : {$in : ['현재','주동','학습']} | |
} | |
}]).toArray(); // 커서를 어레이로 바꿔줍니다 | |
print('질의시작'); | |
/* | |
우왓! 이건 아까 load 한 underscore 라이브러리 입니다.!! | |
mola 컬렉션으로 insert 하는 중이에요 :) | |
*/ | |
_.each(x,function(obj,idx){ | |
print( idx + 1 + '건입력'); | |
db.mola.insert(obj); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment