Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # monger - http://clojuremongodb.info/ ## db 연결 <code clojure> (ns clj.db.mongodb (:require [monger.core :as mg] [monger.collection :as mc] [monger.credentials :as mcr] [monger.query :as mq] [monger.operators :as mo]) (:import [com.mongodb MongoOptions ServerAddress] org.bson.types.ObjectId)) (def mongo-db (let [^MongoOptions opts (mg/mongo-options {:threads-allowed-to-block-for-connection-multiplier 300}) ^ServerAddress sa (mg/server-address mongo-host mongo-port) cred (mcr/create mongo-user mongo-system mongo-password) conn (mg/connect sa opts cred)] (mg/get-db conn "monger-test"))) </code> ## 조회 <code clojure> (def documents-coll "documents") (mc/find-maps mongo-db documents-coll {:age 32}) (mc/find-one-as-map mongo-db documents-coll {:age 31}) (mc/find-map-by-id mongo-db documents-coll (ObjectId.)) (mc/find-maps mongo-db "products" {:price_in_subunits {"$gt" 1200 "$lte" 4000}}) (mc/count mongo-db documents-coll) (mq/with-collection mongo-db documents-coll (mq/find {:age {mo/$gte 30}}) (mq/sort {:age -1}) (mq/batch-size 5000)) </code> ### with-collection 사용시 clj-kondo .[[clj-kondo]]/config.edn <code clojure> {:linters {:invalid-arity {:skip-args [monger.query/with-collection]}}} </code> open/monger.txt Last modified: 2024/10/05 06:15by 127.0.0.1