(delete db-namespace & args)
Delete documents using one or more delete queries (dq ..) Call (delete :testdb.testcoll (dq ...) (dq ..) opt1 opt2 ...) (delete :testdb.testcoll [(dq ...) (dq ..)] {:ordered true} ...) Delete all matching is the default {:limit 0}
Delete documents using one or more delete queries (dq ..) Call (delete :testdb.testcoll (dq ...) (dq ..) opt1 opt2 ...) (delete :testdb.testcoll [(dq ...) (dq ..)] {:ordered true} ...) Delete all matching is the default {:limit 0}
(dq-f & args)
Delete query,one delete command can take one or many dqs Each dq will be a member of :deletes [],see delete command Call (dq filter1 filter2) (dq (>_ age 25) {:comment '...'})
Delete query,one delete command can take one or many dqs Each dq will be a member of :deletes [],see delete command Call (dq filter1 filter2) (dq (>_ age 25) {:comment '...'})
(find-and-modify-f db-namespace & args)
Find and Modify as one step query/update/sort as if it was pipeline stages The rest are options If many match the first document is choosen Call Find-Modify (no upsert) (find-and-modify :testdb.testcoll (=_ :name 'MongoDB') {:name (str- :name '-with-id=1')} (sort- :_id) (fields-o :!_id :name) (new-o))
Upsert (when upsert true => first argument doc(only then)) (find-and-modify :testdb.testcoll {:_id 4} {:name (if- (exist?- :name) (str- :name '-with-id=4') 'new-name')} {:upsert true} ;; upsert => first argument document (fields-o :!_id :name) (new-o))
Find and Modify as one step query/update/sort as if it was pipeline stages The rest are options If many match the first document is choosen Call Find-Modify (no upsert) (find-and-modify :testdb.testcoll (=_ :name 'MongoDB') {:name (str- :name '-with-id=1')} (sort- :_id) (fields-o :!_id :name) (new-o)) Upsert (when upsert true => first argument doc(only then)) (find-and-modify :testdb.testcoll {:_id 4} {:name (if- (exist?- :name) (str- :name '-with-id=4') 'new-name')} {:upsert true} ;; upsert => first argument document (fields-o :!_id :name) (new-o))
(fq-f db-namespace & args)
Find query filters/project/sort/skip/limit as if it was pipeline stages (they are auto converted to find command options) The rest are options Call (fq :testdb.testcoll (>_ :spent 150) (sort- :!spent) [:!id :spent {:aspent (+ :spent 20)}] (skip 5) (limit 1) {:singleBatch true})
Find query filters/project/sort/skip/limit as if it was pipeline stages (they are auto converted to find command options) The rest are options Call (fq :testdb.testcoll (>_ :spent 150) (sort- :!spent) [:!_id :spent {:aspent (+_ :spent 20)}] (skip 5) (limit 1) {:singleBatch true})
(insert db-namespace documents & args)
Call (insert :testdb.testcoll doc option1 option2 ...) (insert :testdb.testcoll [doc1 doc2 ...] option1 option2})
Call (insert :testdb.testcoll doc option1 option2 ...) (insert :testdb.testcoll [doc1 doc2 ...] option1 option2})
(q-count-f db-namespace & args)
Count documents with optional query on them Can be done with aggregation easily query/limit/skip use as aggregate stages Call (q-count :testdb.testcoll (= :dept 'A') ; filters like aggregation (skip 1) (limit 1))
Count documents with optional query on them Can be done with aggregation easily query/limit/skip use as aggregate stages Call (q-count :testdb.testcoll (= :dept 'A') ; filters like aggregation (skip 1) (limit 1))
(q-distinct-f db-namespace & args)
Distinct a field,make it an array,with optinal query first Can be done with aggregation easily Call (q-distinct :testdb.testcoll (not= :dept 'B') {:key 'dept'})
Distinct a field,make it an array,with optinal query first Can be done with aggregation easily Call (q-distinct :testdb.testcoll (not= :dept 'B') {:key 'dept'})
(q-f db-namespace & args)
()->filters {}->addfields []->project Pipeline stages can be nil or nested
Call example (q :testdb.testcoll (>_ :age 25) (=_ :gender 'female') ; filter, both will be 1 match stage with $and and $expr {:pass (>_ :grade 5)} ; addFields (group :hairColor ; :hairColor :count ,here :id will be auto-replaced by :hairColor {:count (sum- 1)}) [:count] ; project,keep only count (> :count 20) ; another filter alone => 1 match stage (sort- :!count) ; sort descending (skip 2) (limit 1))
()->filters {}->addfields []->project Pipeline stages can be nil or nested Call example (q :testdb.testcoll (>_ :age 25) (=_ :gender 'female') ; filter, both will be 1 match stage with $and and $expr {:pass (>_ :grade 5)} ; addFields (group :hairColor ; :hairColor :count ,here :_id will be auto-replaced by :hairColor {:count (sum- 1)}) [:count] ; project,keep only count (>_ :count 20) ; another filter alone => 1 match stage (sort- :!count) ; sort descending (skip 2) (limit 1))
(update- db-namespace & args)
Update documents using one or more update queries uqs Update many is the default {:limit 0} Call (update- :testdb.testcoll (uq ...) (uq ..) opt1 opt2 ...) (update- :testdb.testcoll [(uq ...) (uq ..)] opt1 opt2 ...)
Update documents using one or more update queries uqs Update many is the default {:limit 0} Call (update- :testdb.testcoll (uq ...) (uq ..) opt1 opt2 ...) (update- :testdb.testcoll [(uq ...) (uq ..)] opt1 opt2 ...)
(uq-f & args)
Update query,one update command can take one or many uqs Each uq will be a member of :updates [].see update command uq works only with pipeline updates query is always filters,document is only when {:upsert true} Call (uq (=_ :id 2) {:grade (+ :grade 5)} [:!_id :name])
Upsert (if upsert true => document always as first argument) (uq {:id 4} {:grade (if- (exist?- :grade) (+ :grade 5) 10)} {:upsert true})
Update query,one update command can take one or many uqs Each uq will be a member of :updates [].see update command uq works only with pipeline updates query is always filters,document is only when {:upsert true} Call (uq (=_ :_id 2) {:grade (+_ :grade 5)} [:!_id :name]) Upsert (if upsert true => document always as first argument) (uq {:_id 4} {:grade (if- (exist?- :grade) (+_ :grade 5) 10)} {:upsert true})
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close