extend client with a method to read all documents#41
extend client with a method to read all documents#41jgillich wants to merge 2 commits intochill-rs:masterfrom
Conversation
| #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] | ||
| pub struct DatabaseViewPath { | ||
| db_name: DatabaseName, | ||
| view_name: ViewName, |
There was a problem hiding this comment.
The DatabaseViewPath (and DatabaseViewPathRef) types represent a URI path of the form /db/_all_docs. If I understand this correctly, then view_name should always be the constant _all_docs, and hence view_name is redundant because it doesn't store any information. I suggest removing the view_name field and modifying iteration to always return _all_docs for the view name
path segment.
There was a problem hiding this comment.
There are other paths below db, like /db/_temp_view, that could also be represented by this. But the names could definitely be constants.
There was a problem hiding this comment.
Good point. Long-term, we'll need something that handles additional database sub-paths—be it one type with a sub-path &str or a macro that defines a unique Rust type for each sub-path.
|
Overall, there's a lot of really good work here. Here's some feedback. If cient.read_all_documents("/baseball/_all_docs")
.unwrap()
.reduce(true) // !! Has no meaning for `_all_docs` !!
.run();The ideal is for the application to be incapable of expressing nonsensical actions. For However, adding another type parameter to As for the
Just as a heads up, I'll be out of town for a few days starting tomorrow (Saturday), and I'm not sure whether I'll have Internet access, so I may be a bit unresponsive during that time. |
b7e4d52 to
9062909
Compare
| } | ||
| } | ||
|
|
||
| impl serde::Deserialize for AllDocumentsViewValue { |
There was a problem hiding this comment.
Like 70 LOC just to deserialize a single value object..maybe you know a shorter way to do this.
There was a problem hiding this comment.
The alternative is to use serde_codegen, which introduces its own complexity. For Chill, I prefer to hand-roll serialization and deserialization because:
- The CouchDB API is stable, so,
- Once you write the code for implementing
SerializeorDeserialize, you're done, and the code will rarely change, if ever, and, - The code is mostly copy-and-paste anyway so it's not like it's hard to do.
Whereas, if we needed to continually change our JSON representations because, say, the HTTP API were continually changing, then the advantage would shift in favor of using serde_codegen and we would eat the extra build-time complexity.
Someday, when compiler plug-ins are stabilized in Rust, it will be a no-brainer to rip out the hand-rolled code and use serde macros.
There was a problem hiding this comment.
No doubt, writing them by hand avoids a whole lot of problems. I just find it hard to believe that you'd need that many lines for a seemingly simple task. I recently implemented a deserializer in Elm and that took a single line per field, with static typing and all (although it compiles to JS, maybe that's why). I guess I'm just spoiled by dynamically typed languages. :)
|
|
|
Look like this will help. |
|
Even with that change: https://travis-ci.org/chill-rs/chill/jobs/124559345#L335 😱 I think I'm just going to add some more tests for |
|
Did you update our |
|
Oops how did that happen, I could swear I ran |
|
One of the dependencies pulls in |
ead2523 to
0a3b55b
Compare
|
Sorry for the delay, I've dropped include_docs and rebased on master, should be good to go now. |
|
Awesome! Just give me a few days to review. |
|
I would like to rename Maybe we can get this pull request in by the v0.1.2 release, which I'll be making this weekend. We also need some integration tests for your new action, but I can write those if needed. In other news, I just pushed up a new branch, which will start the v0.2.0 development. The main change is that it vastly simplifies the path-related types, at some cost to run-time performance. The master branch will track v0.1.x until we're ready to commit to full-time v0.2.x development. |
|
|
|
Also, 👍 for the path changes. The performance difference is absolutely irrelevant. |
|
I agree about the verbosity. How about I like the verb + noun convention. Also, I had been avoiding verbs such as We can rename |
|
I released v0.1.2. You should merge/rebase on |
Work in progress, still lacks a representation of the documents in
ViewResponse, deserialization of the rev etc. Hoping to get some feedback, because I don't really like this in its current form.Adds a
DatabaseViewPath, bascially the same asViewPathbut without a design document.ExecuteViewthen stores them in an enum, which makes accessing the path really awkward. MaybeViewPathitself should be an enum, or can you think of something better?ref #39