Skip to content

Commit

Permalink
Update changes to take optargs
Browse files Browse the repository at this point in the history
- Rename changes arg from table to xs
- Add a new arity to changes to pass optargs

Fixes #112, Fixes #76
  • Loading branch information
danielcompton committed Nov 19, 2015
1 parent a402ab9 commit f9e46d4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. This change
## [Unreleased]
### Changed
- Disable Nagle's algorithm (set TCP NO_DELAY to true). This provides a speedup of around 30-40x for small queries on Linux. [#114](https://github.com/apa512/clj-rethinkdb/pull/114)
- Added a new arity to `changes` that allows you to pass optargs. [#112](https://github.com/apa512/clj-rethinkdb/issues/112)
- Renamed changes arg from `table` to `xs`. [#76](https://github.com/apa512/clj-rethinkdb/issues/76)


## [0.11.0] - 2015-10-19
Expand Down
10 changes: 6 additions & 4 deletions src/rethinkdb/query.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@
(term :INDEX_WAIT (concat [table] index-names)))

(defn changes
"Return an infinite stream of objects representing changes to a table or a
document."
[table]
(term :CHANGES [table]))
"Return an infinite stream of objects representing changes to a table, sequence,
or a document."
([xs]
(term :CHANGES [xs]))
([xs optargs]
(term :CHANGES [xs] optargs)))

;;; Writing data

Expand Down
6 changes: 3 additions & 3 deletions test/rethinkdb/core_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@
(r/run (-> (r/db test-db)
(r/table test-table)
(r/insert (take 2 (repeat {:name "Test"})))) conn)
(is (= "Test" ((comp :name :new_val) (first @changes))))))
(is (= "Test" (get-in (first @changes) [:new_val :name])))))
(with-open [conn (r/connect :db test-db)]
(let [changes (future
(-> (r/db test-db)
(r/table test-table)
r/changes
(r/changes {:include-states true})
(r/run conn)))]
(Thread/sleep 500)
(r/run (-> (r/table test-table)
(r/insert (take 2 (repeat {:name "Test"}))))
conn)
(is (= "Test" ((comp :name :new_val) (first @changes)))))))
(is (= {:state "ready"} (first @changes))))))

(deftest document-manipulation
(with-open [conn (r/connect :db test-db)]
Expand Down

0 comments on commit f9e46d4

Please # to comment.