기본 콘텐츠로 건너뛰기

라벨이 mongodb인 게시물 표시

openshift 에 nodebb 를 올려보자.

rhc 그러니까 옛날 버전 기준이다. 요즘껀 도대체 뭐가 뭔지 모르겠어. 잊지 않겠다 Kubernetes.. o>< rhc app create --no-scaling nodebb https://raw.githubusercontent.com/icflorescu/openshift-cartridge-nodejs/master/metadata/manifest.yml rhc cartridge add https://raw.githubusercontent.com/icflorescu/openshift-cartridge-mongodb/master/metadata/manifest.yml -a nodebb https://github.com/icflorescu/openshift-cartridge-nodejs/issues/55 참조. node.js 버전을 지정하려면 semver.io를 참조. NODE_VERSION_URL 환경 변수도 바꿔줘야한다. rhc env set -a [어플리케이션 이름] NODE_VERSION_URL=https://semver.io/node/resolve/4 (https://semver.io/node 가 안정버전, https://semver.io/node/unstable 이 최신이다) 일단, NODE_VERSION_URL 을 지정하지 않았으므로 최신(unstable) node.js 설치를 할거다. app create를 하면 nodebb 디렉토리를 만드는데 cd nodebb git remote add upstream -m master https://github.com/NodeBB/NodeBB.git rm -rf `ls` .eslintrc && git commit -a -m 'Cleaned up for NodeBB' git pull --no-edit -s recursive -X theirs upstream master 순으로 하자. upstream에서 가져올 때 ...

map과 reduce를 사용하여 distinct(group by) 하는 방법

oracle 같은 RDB 를 다루던 시절엔 user | dept ----------- john | 0000 tom | 0001 jack | 0000 jane | 0001 과 같은 형태의 테이블일때 부서의 목록을 뽑아 내고자 group by 나 distinct 를 사용하여 dept ----- 0000 0001 이와 같이 뽑아내곤 했는데 noSQL 을 사용하거나 array collection 형태의 데이터를 다룰때에도 이런 작업을 해야할 경우가 있다. 일단 예제로 다뤄볼 대상 collection 의 구조를 가정해 보자. documents = [   {     _id: "........",     message: "......",     user : {       _id: "........",       profile: {         displayName: "....."       }     } ] 흔한 게시판 형태의 데이터 구조라고 볼 수 있는데 각 documents 마다 고유한 _id 를 가지고 있고 해당 documents 를 작성한 user 객체가 각각 들어있는 경우라고 볼 수 있다. 그렇다면 documents 를 작성한 user 의 목록을 뽑아낼 수는 없을까? node 콘솔이나 브라우저용 개발 툴에서 복사 붙이기 용으로 코드를 예제 코드를 한번 넣어보자면 documents = [ { _id: "doc0001", message: "document 01", user: { _id: "user0001", profile: { displayName: "john", } } }, { _id: "doc0002", message: "document 02", us...