3 ms·
I actually didn't have the same problems with the clojure rethinkdb driver. I'll address my opinions in turn: - query builder reliance I'm not sure what you m
by hardwaresofton 11y ago
I actually didn't have the same problems with the clojure rethinkdb driver. I'll address my opinions in turn:
- query builder reliance
I'm not sure what you mean by this? I got a lot of mileage out of the library by writing partial functions that generate queries that were most commonly used. So, I'd have functions like:
(def find-user-by-id
"Find a user by ID"
[id]
(-> (r/db "database")
(r/table "users")
(r/find id)))
or something similar. Of course, you can get a lot more generic with this -- but I found that keeping these queries with each other created good separation of "database-stuff" from the rest of my app (and made it easy for me to do versioning.
- Needing to look in the codebase for documentation on how to use the methods
While this is certainly unfortunate (and I belive true), I have found that it's actually good advice to tell someone to look at tests in a repo as backup-documentation on projects that are far along enough to have tests. Also... this is kind of a problem with the clojure ecosystem in general, so I'd definitely +1.
Would like to take this moment to also thank apa512 for writing the library, thanks for doing so!
I think I ran into a problem once when working on changefeeds (the default implementation used a seq and I think I wanted a channel or something like that), but that boiled down to me misunderstanding how to use it, rather than it being "wrong" in a sense.
- krat0sprakhar 11y agoQueries like the one you wrote above are indeed quite idiomatic but something as simple as providing a `read_mode` requires a query builder- (r/get (rethinkdb.query-builder/term :TABLE [(query/db db) table] {:read_mode read_mode}) id)])) whereas in JS, you can simply do r.db('heroes').table('marvel', {readMode: 'outdated'}).run(conn, callback)
- hardwaresofton 11y agoThanks for the example -- while I have never needed to actually change the read mode, you shouldn't need to actually use that query buider, read mode is an optional argument to r/table. Apologize if I misunderstood what you were trying to do, or if this was a relatively recent addition that wasn't available last you used clj-rethinkdb. Here's an example (from tests in the repo): https://github.com/apa512/clj-rethinkdb/blob/1cd09c7c8a4ce271a6cd35fdaa023c823b3465e1/test/rethinkdb/core_test.clj#L122 https://github.com/apa512/clj-rethinkdb/blob/1cd09c7c8a4ce27...