Commit graph

332 commits

Author SHA1 Message Date
Michael S. Klishin
75bb240af9 Add monger.collection/system-collection?, a convenience function
We don't add it to the change log because the majority of apps won't use it and
it is not an important change between RC1 and RC2 (or what may even be 1.0).
2012-06-10 12:35:52 +04:00
Michael S. Klishin
898349f95a A couple more convenience functions 2012-06-09 11:25:48 +04:00
Michael S. Klishin
12f48b058b Remove type hints that can be inferred by the compiler, part 3 2012-06-09 00:36:07 +04:00
Michael S. Klishin
5813f61649 Eliminate this reflection warning
Unfortunately, because Java driver's return type is so generic (Iterable),
we have to do it by type hinting what is really returned as the result set
(by inspecting the Java driver code paths).
2012-06-09 00:33:55 +04:00
Michael S. Klishin
e008e0d18d Remove type hints that can be inferred by the compiler, part 2 2012-06-09 00:26:23 +04:00
Michael S. Klishin
423b80774a Remove type hints that can be inferred by the compiler, part 1 2012-06-09 00:23:01 +04:00
Michael S. Klishin
91d967b592 Inlining, part 2 2012-06-09 00:20:55 +04:00
Michael S. Klishin
2a64afa6ff Inlining, part 1
We inline collection getter not so much as an optimization technique (HotSpot will inline all that anyway) but
mostly to remove let forms that do not make any difference to the (human) reader.
2012-06-09 00:14:19 +04:00
Michael S. Klishin
824a532590 Cosmetics 2012-06-09 00:12:26 +04:00
Michael S. Klishin
d12f33e1e8 Better authentication failure message 2012-06-08 22:14:59 +04:00
Michael S. Klishin
f07f577094 Cosmetics 2012-06-08 22:09:17 +04:00
Michael S. Klishin
d824e622c3 Derp 2012-06-08 22:07:16 +04:00
Michael S. Klishin
1184fce8c3 Add a few more commands that may be useful to JVM-based applications
Clojure is unlikely to be a good choice for devops tools, so we don't
implement convenience functions for sharding, replication, et cetera.
2012-06-08 22:04:46 +04:00
Michael S. Klishin
babd429f5b Implement monger.result/ok? for Clojure maps 2012-06-08 11:56:00 +04:00
Michael S. Klishin
6e43328941 New higher-level DSL for storing files on GridFS
References #27
2012-06-04 14:46:13 +04:00
Michael S. Klishin
a6544a1617 Make sure gridfs finders never go into infinite recursion
Protocol matching is hash-based, so we cannot guarantee that DBObject implementation will
always be picked before java.util.Map's.
2012-06-04 14:15:12 +04:00
Michael S. Klishin
e033aa995b More gridfs support improvements
References #27
2012-06-04 14:03:45 +04:00
Michael S. Klishin
d79e35790f Make sure namespaces that use monger.gridfs/make-input-file don't have to import GridFSInputFile 2012-06-04 13:24:58 +04:00
Michael S. Klishin
01773f50d5 Better coverage for storing files in gridfs, include file metadata
References #27
2012-06-04 13:11:31 +04:00
Michael S. Klishin
5964e01b1d Make :auto-connect-retry connection default to true
Another very unsafe default on the MongoDB Java driver side. Monger puts safety first, fancy
sky high benchmarks second.
2012-05-28 02:22:46 +04:00
Michael S. Klishin
63f7099350 MongoDB 2.1 Aggregation Framework support 2012-05-28 00:43:45 +04:00
Michael S. Klishin
dd9d1c3bfd The rest of 2.1/2.2 Aggregation framework operator macros 2012-05-25 23:49:57 +04:00
Michael S. Klishin
47cc9a0363 $limit and $skip operator macros 2012-05-25 23:44:44 +04:00
Michael S. Klishin
3360c2e96c $group operator macro 2012-05-25 23:26:11 +04:00
Michael S. Klishin
6a7ac2f1b3 $match, $project, $unwind operator macros 2012-05-25 23:24:30 +04:00
Michael S. Klishin
acdaffba99 Add $regex and $options operator macros 2012-05-25 14:39:35 +04:00
Michael S. Klishin
0db4bc6e11 Minor docstring improvements 2012-05-22 18:46:15 +04:00
Baishampayan Ghose
79fa31304a Use alter-var-root instead of def in set-write-concern!.
Using `def` there is unnecessary and redundant.
2012-05-15 17:31:04 +05:30
Baishampayan Ghose
75fd7f5c91 Add support for connecting to Replica Sets.
Monger can now connect to replica sets using one or more seeds when
calling monger.core/connect with a vector (or list) of server-addresses
instead of just a single one.

For example -

;; Connect to a single MongoDB instance
(connect (server-address "127.0.0.1" 27017) (mongo-options))

;; Connect to a replica set
(connect [(server-address "127.0.0.1" 27017)
          (server-address "127.0.0.1" 27018)]
         (mongo-options))

Since connect! just applies connect to all the args, it works fine there
as well.
2012-05-15 11:33:40 +05:30
Michael S. Klishin
87184af396 Initial Ring session store implementation 2012-05-14 16:10:55 +04:00
Baishampayan Ghose
43cddbcf57 Remove redundant invocation of to-db-object on top of as-field-selector.
`as-field-selector` already returns a DBObject, so there is no need to call `to-db-object` on top of the return value.
2012-05-12 11:00:33 +05:30
Michael S. Klishin
1d54e00a4d Change log update, copyright header update 2012-05-12 07:44:40 +04:00
Baishampayan Ghose
ccd3d7ab66 Add monger.collection/find-and-modify and associated tests. 2012-05-12 09:02:19 +05:30
Michael S. Klishin
8142d02f01 Deprecate monger.js (moved to clojurewerkz.support.js) 2012-05-03 01:06:41 +04:00
Michael S. Klishin
d04ab3af2d More cleanup 2012-05-01 16:35:33 +04:00
Michael S. Klishin
c36a0abe8c Use clojurewerkz.support 0.2.0 2012-04-26 21:14:48 +04:00
Michael S. Klishin
5341344e97 Remove type hints that are not guaranteed to be correct 100% of the time 2012-04-24 09:38:21 +04:00
Michael S. Klishin
444017fde2 Define several more operators 2012-04-23 15:01:13 +04:00
Michael S. Klishin
6a2698dce2 Support serialization of Clojure sets (or anything that implements java.util.Set) 2012-04-16 02:32:28 +04:00
Michael S. Klishin
ceeac55496 A more efficient implementation of clojure.core.cache/has? for BasicMongerCache 2012-04-12 17:12:08 +04:00
Michael S. Klishin
2c9cce8466 Capped collections support 2012-04-12 06:10:08 +04:00
Michael S. Klishin
d203f27479 Cosmetics 2012-04-12 06:09:54 +04:00
Michael S. Klishin
90171ac2d1 Two faster paths for strings and dates 2012-04-11 20:59:20 +04:00
Michael S. Klishin
28831c61da Initial monger.cache version, implements clojure.core.cache/CacheProtocol only 2012-04-11 20:58:05 +04:00
Michael S. Klishin
e425bc84ea Support DBObject conversion for all objects that implement clojure.lang.Named, not just keywords 2012-04-11 20:57:31 +04:00
Michael S. Klishin
30a4ae4ea0 Don't assume ids are ObjectId instances (for caches it may be different) 2012-04-11 20:56:47 +04:00
Michael S. Klishin
7ef48e9bb4 Eliminate reflection warnings 2012-04-11 20:56:22 +04:00
Michael S. Klishin
19b8e48084 Make sure we authenticate before calling set-db! (which instantiates a GridFS object)
Fixes Heroku/MongoHQ add-on issues
2012-04-11 01:33:29 +04:00
Michael S. Klishin
6e7c29ba8b Improve support for URI connections 2012-04-11 00:20:07 +04:00
Michael S. Klishin
0da0a696f2 Initial support for URI connections.
I want to believe that the person who designed MongoDB Java driver API was not sober while at it.
2012-04-10 23:54:23 +04:00
Michael S. Klishin
a6d15dbbe1 Extend monger.core/count to MapReduceOutput 2012-04-10 19:16:21 +04:00
Michael S. Klishin
876269e81a Use 127.0.0.1 as default host 2012-04-07 07:42:13 +04:00
Michael S. Klishin
c23a589620 Correct comment 2012-04-04 23:23:31 +04:00
Michael S. Klishin
6282f41f06 Support field negation in queries, closes #17 2012-04-04 23:08:05 +04:00
Michael S. Klishin
0530b165f6 Add support for index options + unique indexes for monger.collection/ensure-index and monger.collection/create-index 2012-04-03 16:42:48 +04:00
Michael S. Klishin
f0d190cff7 Support conversion of Clojure ratios to MongoDB data types
We go with doubles because it is the only realistic solution that is
interoperable with all other technologies. Plus, Clojure ratios are just
lazily evaluated doubles anyway.
2012-04-02 12:14:24 +04:00
Michael S. Klishin
1db1e04b0a monger.testing => monger.testkit
If nothing else, this will save everyone some headaches trying to figure out
conflicts between testing the namespace alias and clojure.test/testing (the function)
2012-03-21 19:36:48 +04:00
Michael S. Klishin
cedfecbbbd Introduce monger.testing/memoized-oid (convenience function for defining referenced associations) 2012-03-08 12:18:02 +04:00
Michael S. Klishin
425327aafa Introduce monger.testing/seed-all 2012-03-07 13:02:59 +04:00
Michael S. Klishin
dfb7bd3fc8 Remember object ids of inserted documents 2012-03-07 11:33:32 +04:00
Michael S. Klishin
0154e33470 Implement parent-id seeding in the factory DSL 2012-03-07 10:21:57 +04:00
Michael S. Klishin
94abe56605 Initial support for child => parent references in factories 2012-03-06 21:13:34 +04:00
Michael S. Klishin
5a2ab1a22b Make monger.internal.fn/expand-all-with more flexible 2012-03-06 19:44:23 +04:00
Michael S. Klishin
9b9005448b Implement monger.internal.fn/expand-all-with 2012-03-06 19:38:40 +04:00
Michael S. Klishin
c1409eb81e Test case with child documents embedded into parent now passes 2012-03-06 12:07:02 +04:00
Michael S. Klishin
a2eb9ce964 Also expand vector values that are functions 2012-03-06 12:02:26 +04:00
Michael S. Klishin
2e47407ef0 Implement expansion (evaluation) of function values in factories 2012-03-06 11:35:35 +04:00
Michael S. Klishin
b9016aff99 Implement recursive function value expansion (for maps) 2012-03-06 11:30:01 +04:00
Michael S. Klishin
e54bd37932 Cached object ids won't work, per (long) discussion with Alex 2012-03-05 20:55:08 +04:00
Michael S. Klishin
0f867b8236 Implement seeding (insertion) of factory-built documents, add (experimental) oid-of function
We will see if caching object ids is a viable idea, it is not obvious at this point
2012-03-05 18:10:36 +04:00
Michael S. Klishin
19a55b5a5b Initial factory/fixture DSL bits 2012-03-05 17:09:59 +04:00
Michael S. Klishin
63d40179fe Switch monger.core to alter-var-root
Previous implementation was almost literally my first code in Clojure. Needless to say it sucked.
2012-02-28 20:23:50 +04:00
Michael S. Klishin
a09c55096c Add ability to connect using ServerAddress and MongoOptions, closes #15 2012-02-28 20:08:05 +04:00
Michael S. Klishin
60688e7482 Merge branch 'toby-commands' 2012-02-21 15:06:29 +04:00
Toby Hede
f36528b592 command namespace and basic commands 2012-02-21 13:02:01 +11:00
Toby Hede
d982d27caa core/command accepts db as explicit parameter option 2012-02-21 13:01:42 +11:00
Michael S. Klishin
7747325030 Make monger.core/get-db-names return a set 2012-02-20 16:06:05 +04:00
Michael Klishin
7348ca9f2e Merge pull request #12 from tobyhede/63870b1136e63865ba349faa159d473b3cab79a7
new core/get-db-names
2012-02-20 04:00:40 -08:00
Toby Hede
63870b1136 add get-db-names to core 2012-02-20 22:46:07 +11:00
Michael S. Klishin
96d5b4a66f Eliminate recently introduced reflection warnings 2012-02-19 05:32:50 +04:00
Michael S. Klishin
345ee691eb Introduce monger.collection/remove-by-id 2012-02-18 19:02:43 +04:00
Michael S. Klishin
fdcad90cd8 Introduce monger.collection/update-by-id 2012-02-18 18:56:34 +04:00
Michael S. Klishin
6c1dcdcc89 One more copyright header update [ci skip] 2012-02-18 16:31:39 +04:00
Michael S. Klishin
88f8789093 Update license headers [ci skip] 2012-02-18 16:30:36 +04:00
Michael S. Klishin
e29655a7fd Cosmetics 2012-02-18 15:46:18 +04:00
Michael Klishin
1494cc5ad4 Merge pull request #11 from tobyhede/b51aae652403e98c4979191bfda60a776272836f
monger.db namespace and funcs
2012-02-18 03:43:06 -08:00
Toby Hede
157cbc698f amend find-map-by-id to accept fields as 3rd parameter
fix atomic update tests that broke … being passed fields as the param, but mismatch in api
2012-02-18 21:57:45 +11:00
Toby Hede
b51aae6524 clarified documentation for drop-database 2012-02-18 12:18:03 +11:00
Toby Hede
3151587d67 add-user and test, db ns 2012-02-17 19:12:16 +11:00
Toby Hede
62e0fb945e test for drop database 2012-02-15 21:32:45 +11:00
Toby Hede
300220da15 moved get-collection-names to new db ns 2012-02-15 21:00:01 +11:00
Toby Hede
d5cce8c97b Merge remote-tracking branch 'upstream/master' 2012-02-14 21:49:56 +11:00
Toby Hede
66e5e929ad add get-collections-names to core 2012-02-14 21:48:59 +11:00
Michael S. Klishin
f6a80fa40a Make sure monger.collection/find-by-id and /find-map-by-id fail fast when id is nil 2012-02-13 22:52:03 +04:00
Michael S. Klishin
7553925250 Correct docstring [ci skip] 2012-02-12 20:39:23 +04:00
Michael S. Klishin
fe421cc0db Make it possible to opt-out of field keywordization in the query DSL
An example:

``` clojure
(with-collection coll
  (find {})
  (limit 3)
  (sort { :population -1 })
  (keywordize-fields false))
```
2012-02-12 10:13:39 +04:00
Michael S. Klishin
3aa842fb04 Remove commented out code 2012-02-12 09:52:55 +04:00
Toby Hede
31aff189d3 find-one-as-map accepts fields as 3rd parameter
partial resolution of: https://github.com/michaelklishin/monger/issues/8
2012-02-12 15:43:33 +11:00
Michael S. Klishin
d2408faea6 Introduce monger.core/authenticate 2012-02-02 09:53:26 +04:00
Michael S. Klishin
8f6c5cdf2a Add explicit GridFS instance parameter to monger.gridfs/remove, /remove-all and /all-files
Unfortunately, we cannot do the same for functions that implement GridFS-related protocols.
2012-01-29 07:56:13 +04:00
Michael S. Klishin
0bfe0582c0 Ditto for monger.collection/find and friends 2012-01-29 07:51:21 +04:00
Michael S. Klishin
df7802796a Cosmetics 2012-01-29 07:40:21 +04:00
Michael S. Klishin
4d30f1625d Ditto for monger.collection/create-index 2012-01-29 07:39:51 +04:00
Michael S. Klishin
b30071a2b3 Ditto for monger.collection/exists?, /drop-index and /drop-indexes 2012-01-29 07:38:28 +04:00
Michael S. Klishin
025e8fce45 Ditto for monger.collection/create 2012-01-29 07:30:11 +04:00
Michael S. Klishin
76a3eafd5d Ditto for monger.collection/drop 2012-01-29 07:29:30 +04:00
Michael S. Klishin
dccb4770f1 Ditto for monger.collection/rename 2012-01-29 07:28:37 +04:00
Michael S. Klishin
3df399c2be Ditto for monger.collection/distinct 2012-01-29 07:26:21 +04:00
Michael S. Klishin
b76cffcd1a Ditto for monger.collection/save 2012-01-29 06:58:02 +04:00
Michael S. Klishin
afa516fff6 Explicit database parameter for monger.collection/insert-batch, /count, /empty?, /any? 2012-01-29 06:31:28 +04:00
Michael S. Klishin
e5af694cc7 Support explicit database parameter for monger.collection/insert 2012-01-29 06:04:11 +04:00
Oleksandr Petrov
9af8a13ea9 Merge branch 'master' of https://github.com/michaelklishin/monger 2012-01-25 21:56:09 +01:00
Oleksandr Petrov
7ab8d51a84 Adding missing $nin operator. 2012-01-25 21:56:06 +01:00
Michael S. Klishin
a3d6a66eb1 Use GridFS/DEFAULT_CHUNKSIZE instead of our own default
Ruby driver uses 2 MB default chunk size, Java driver uses 256K. Lets use what the Java driver
does.
2011-12-31 16:55:32 +04:00
Michael S. Klishin
1187719ac1 Extend monger.gridfs.GridFSInputFileFactory to support input streams 2011-12-31 16:52:23 +04:00
Michael S. Klishin
cb9ed8edb5 monger.gridfs/find-one-as-map is next to useless, remove it
It does not allow you access file content stream.
2011-12-31 16:27:56 +04:00
Michael S. Klishin
a292f082e8 Implement monger.gridfs/find-one and /find-one-as-map 2011-12-31 16:23:49 +04:00
Michael S. Klishin
7da99d98a3 Implement monger.gridfs.GridFSInputFileFactory for java.io.File instances 2011-12-31 15:01:00 +04:00
Michael S. Klishin
ced9b50153 Make monger.gridfs.IOFactory implementation for String to work the same way as clojure.java.io/IOFactory one does
It treats string arguments as local filesystem paths
2011-12-31 14:57:17 +04:00
Michael S. Klishin
bb806d5c0f Remove unused DSL support functions 2011-12-31 07:03:15 +04:00
Michael S. Klishin
d0f2cbc737 Add monger.core/*mongodb-gridfs* and related with-* macro. Blow the dust off monger.core along the way. 2011-12-31 06:57:29 +04:00
Michael S. Klishin
eab4405012 Initial bits of monger.gridfs 2011-12-31 06:56:02 +04:00
Michael S. Klishin
3c813132d8 Return type of monger.conversion/to-db-object is always the same, hint it 2011-12-31 06:44:34 +04:00
Michael S. Klishin
f3efbcec16 One more query DSL composition example, introduce monger.query/partial-query 2011-12-31 04:25:26 +04:00
Michael S. Klishin
8300b7c0c4 Eliminate compiler warning 2011-12-31 04:24:27 +04:00
Michael S. Klishin
1cb024dcad Add read preference support for monger.query DSL 2011-12-30 17:19:44 +04:00
Michael S. Klishin
c25609a5c3 monger.conversion/to-object-id 2011-12-28 19:46:47 +04:00
Oleksandr Petrov
1a8eb1ef80 Added docs, improved test suite.
Removed (seq) method call from find-maps, since DBCursor implements Iterable interface. 
Added empty? method for collection.
2011-12-23 11:56:14 +01:00
Michael S. Klishin
57c4ad6e9b Switch to clojure.java.io/resource here 2011-12-16 11:12:55 +04:00
Michael S. Klishin
f49e272f9f Introduce monger.testing/defcleaner that supposed to be used with clojure.test/use-fixtures 2011-12-16 07:18:16 +04:00
Oleksandr Petrov
e6f81e52a7 Merge branch 'master' of https://github.com/michaelklishin/monger 2011-12-03 18:40:52 +01:00
Oleksandr Petrov
16d02800d3 Commenting code, adding docs. 2011-12-03 18:39:17 +01:00
Oleksandr Petrov
611d9666bd Added get-write-concern function. 2011-12-03 18:39:02 +01:00
Oleksandr Petrov
f2a5786ad4 Adding some docs. 2011-11-30 22:07:40 +01:00
Michael S. Klishin
8127d26442 Fix monger.util/get-id for persistent maps with string keys 2011-11-29 15:44:55 +04:00
Michael S. Klishin
be06397849 Introduce monger.collection/any?
Useful for detecting duplicate documents and so on
2011-11-28 20:12:19 +04:00
Oleksandr Petrov
578673a058 Writing docs 2011-11-25 17:58:35 +01:00
Oleksandr Petrov
1124316793 Adding some docs for operators. 2011-11-25 17:33:23 +01:00
Oleksandr Petrov
9664961120 Adding some docs to querying. 2011-11-19 23:41:36 +01:00
Michael S. Klishin
d9f5ae5951 Move pagination helper to monger.internal.pagination 2011-11-15 03:48:31 +04:00
Michael S. Klishin
3534e579b7 Add pagination support to monger.query DSL
An example:

(with-collection coll
                  (find {})
                  (paginate :page 1 :per-page 3)
                  (sort { :title 1 }))
2011-11-15 03:44:19 +04:00
Michael S. Klishin
0536244dce Merge branch 'master' into query-dsl
Conflicts:
	src/monger/operators.clj
2011-11-14 15:23:47 +04:00
Michael S. Klishin
bd133c1afc Initial version of the monger.query DSL
Here is what it looks like:

(with-collection "docs"
  (find { :inception_year { $lt 2000 $gte 2011 } })
  (fields { :inception_year 1 :name 1 })
  (skip 10)
  (limit 20)
  (batch-size 50)
  (hint "my-index-name")
  (snapshot))
2011-11-14 15:15:43 +04:00
Michael S. Klishin
c40b0e25c1 Simplify defoperator 2011-11-12 20:46:34 +04:00
Michael S. Klishin
0b242f9586 Add operator 2011-11-12 20:33:02 +04:00
Oleksandr Petrov
047d5b6a88 Separating operators to Logical Operators, Query Operators and Atomic Modifiers.
Adding docs to most of operators (still TBC), giving more examples, improving test suite.
2011-11-11 18:55:43 +01:00
Oleksandr Petrov
df12686708 Making defoperator private by default 2011-11-11 18:54:11 +01:00
Michael S. Klishin
c109702117 Rewort $operator macros to evaluate to strings and not functions
Unlike Casbah and Korma, we already use query language data structures as close to what MongoDB uses as possible
(Clojure maps, vectors, numerics and strings are effectively JSON) so we don't need any layers on top, they won't improve
anything.

Having these operators is nice beacuse if you use atomic operators a lot, this will make sure Clojure compiler catches
typos for you. It is completely opt-in, however.

Finally, having a function inserted carries certain runtime performance cost and having $operator macros
that evaluate to themselves does not.

Per discussion with Alex.
2011-11-09 12:40:22 +04:00
Oleksandr Petrov
bb169d3ae3 Adding operators DSL in order to use Clojure functions instead of hashes.
Casbah has a similar concept called Bareword Operators.
Korma uses operators a bit differently, but idea is quite same, too. 

One of the obvious advantages is that you can make sure you didn't screw make a typo 
in operator name during compile-time. Plus, we can guarantee that there is a subset
of used / supported operators, and add them gradually, keeping track of them in one place, 
which will simplify tests, too.
2011-11-08 00:12:10 +01:00
Michael S. Klishin
758fb9e7e6 Support skip & limit for monger.collection/find and /find-maps
As test example demonstrates, closely following DBCollection and DBCursor API has one downside:
queries that use sorting look really ugly. So monger needs to come up with a DSL à la Casbah or SQLKorma
to make this really nice.
2011-11-05 09:45:54 +04:00