본문 바로가기

Database10

c언어 mongodb_document 구성 Document 구성 방법BSON 또는 BCON을 이용할 수 있다.BCON이 더 직관적이고 가독성이 높기 때문에 BCON을 이용한다.JSON을 파싱할 또는 이용하여 만들 때는 BSON을 이용 하는듯 하다. 만들 예재:{ born : ISODate("1906-12-09"), name : { first : "Grace", last : "Hopper" }, languages : [ "MATH-MATIC", "FLOW-MATIC", "COBOL" ], degrees: [ { degree: "BA", school: "Vassar" }, { degree: "PhD", school: "Yale" } ] } #include int main (int argc, char *argv[]){ struct tm born = {.. 2017. 2. 17.
c언어 mongodb 연동 다음 코드를 실행하면 설정한 db의 collection에 hello:world(키:값) 을 추가 해준다. #include #include #include #include int main (int argc,char *argv[]){ mongoc_client_t *client; // DB주소를 담을 변수 mongoc_database_t *database; // DB이름을 담을 변수 mongoc_collection_t *collection; // collection 이름을 담을 변수 bson_t *command, // mongodb에서 사용할 명령어 reply, *insert; bson_error_t error; char *str; bool retval; mongoc_init (); // mongoc 시작(제.. 2017. 2. 17.
c언어 mongodb 연동_설치 본 글의 기준은 ubunut 16.04기준 입니다. Debian 계열 리눅스면은 아래 대로 진행하셔도 무방할 것 입니다. 1. sudo apt-get install libmongoc-1.0-0 2. sudo apt-get install pkg-config libssl-dev libsasl2-dev 3. sudo apt-get install git gcc automake autoconf libtool 4. git clone https://github.com/mongodb/mongo-c-driver.git 5. cd mongo-c-driver 6. ./autogen.sh --with-libbson=bundled 7. make 8. sudo make install 9. ./configure --enable-h.. 2017. 2. 17.
Ubuntu 16.04에서 MongoDB 설치하기 우분투 버전은 16.04 LTS입니다. 12.04LTS, 14.04LTS를 쓰시는 분은 실행 명령이 조금 다릅니다. 16.04LTS버전을 기준으로 설명하겠습니다. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.listsudo apt-get updatesudo apt-get install -y mongodb-orgsudo apt-get install -y mongodb-org=3.2.10 m.. 2016. 11. 16.