mibes / couch-rs Goto Github PK
View Code? Open in Web Editor NEWCouchDB library for Rust
License: Apache License 2.0
CouchDB library for Rust
License: Apache License 2.0
Hi,
I see CouchDB 3.0 implemented partitioned databases which helps with earlier implementation pattern of using types in documents for supporting segregation. Was looking to use the lib for a project with partitioned databases, but didn't find it supported. Please correct if I missed the support already present or if there is a roadmap for that to be upstreamed soon.
If it hasn't yet been worked on, would you be willing to accept contributions around partitioned databases? (Although it should mostly be minor toying around with URLs)
Hi!
Thank you for great job with this crate! It's really helpful & I'm intensively using it in the production.
I've observed that method exists returns true even if database does not exists.
I'm attaching the screenshot from the debugger. As you see - somewhere deep inside http::status::StatusCode is 404
, but method returns true
.
The docs for insert_index says:
Inserts an index in a naive way, if it already exists, will throw an Err
This is not accurate. When an index already exists, the DesignCreated::results
field will be "exists" and no error will be thrown. Because of this behavior, the ensure_index
method on Database
doesn't really have any purpose.
In my mind, the primary purpose of a method like ensure_index
is to run in a 'migration' job before an application depending on couch_rs is launched. A method like this would ensure that the database in question has the indexes that are expected by the application code.
I propose the following changes:
insert_index
to reflect its actual behavior.insert_index
to match the types::index::Index
struct, to make it more compatible with the get_indexes
method.IndexType
as defined in the CouchDB docsensure_index
function that will take a vector of Index and either validate that they exist in the database or create them.For the pageable query, is there any way to return the affect rows for specific offset and limit count, and with the total rows for the specific query condition...
Upgrade to tokio 1.0 once the reqwest dependency has been upgraded (seanmonstar/reqwest#1060). Reqwest in turn, is waiting on hyper 0.14 (hyperium/hyper#2352) which will wait on tokio 1.0 that is due end of 2020.
Hi all,
When creating a db object through client.db() method, I'm overflowing stack quite frequently when calling from tokio workers. Is this expected (as in Database is a heavy object) and I should be using a Box ? I was theorizing that all couch-rs objects will be small in size as its just a http client to the couch.
Let me know what would be the recommended practice in this case.
couch-rs
currently uses reqwest and hyper for its underlying web framework. In the case of an application that uses the actix stack as its web framework, this adds close to 100 dependencies and offers significant bloat to the executable (and, incidentally, about 2-3 minutes of build time with Github actions runners)
This package should optionally use the reqwest/hyper stack or the actix stack as its underlying framework.
It's not easy to tell if a CouchError
originated from something like a failure to Deserialize or some other cause. This is because CouchError
is a struct rather than an enum and multiple items all get the same status:
couch-rs/couch_rs/src/error.rs
Lines 74 to 102 in f15ba8b
Consider making CouchError
an enum so downstream consumers can match over the Error types and not have to resort to string matching on message.
reqwest
uses native-tls
by default, which requires openssl in os. for example, this project won't build on replit.
Add a delete index function that will call DELETE on _index
.
This functionality will be required for a CouchDB "migration tool" that will allow programmatic control of indices from rust code.
The remove function signature:
pub async fn remove<T: TypedCouchDocument>(&self, doc: &T) -> bool
does not return a Result like the function signatures for other 'CRUD' operations create, save and upsert.
Remove should be changed (or possibly deprecated and replaced with a new 'delete') to return a CouchResult so that any errors as well as the http status for the db call call can be returned.
https://replicate.npmjs.com exposes couchdb's _changes
api. when using this library to query it, it reports error
CouchError { id: None, status: 501, message: "data did not match any variant of untagged enum Event" }
The code is
use anyhow::Result;
use futures_util::stream::StreamExt;
#[tokio::main]
async fn main() -> Result<()> {
let client = couch_rs::Client::new_no_auth("https://replicate.npmjs.com")?;
let db = client.db("").await?;
let mut changes = db.changes(None);
changes.set_infinite(true);
let mut events = vec![];
while let Some(change) = changes.next().await {
match change {
Ok(c) => {
events.push(c);
if events.len() == 10 {
break;
}
}
Err(e) => println!("error: {:?}", e),
}
}
println!("{:?}", &events);
Ok(())
}
bulk_upsert does crash constantly with new data sent. Resulting in a 500 message "Response does not match request". Looping through the slice with the normal upsert function works just fine. Also, updating existing data works smoothly with the bulk_upsert function.
error: failed to parse manifest at /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/couch_rs-0.8.33/Cargo.toml
Caused by:
feature edition2021
is required
this Cargo does not support nightly features, but if you
switch to nightly channel you can add
cargo-features = ["edition2021"]
to enable this feature
This is causing a big problem for me because I'm trying to stay on rust 1.53 due to some other linker problem. I can't build new versions of my webserver now, until I can figure out how to upgrade to 1.56 and edition 2021.
It seems like any include of couch_rs 0.8.32 is still pulling the 0.8.33 version.
I wish you would have made this last release version 0.9 to make this upgrade easy for me.
I made a crate to help test couch_rs.
Docs: https://docs.rs/couch_rs_test/0.2.0/couch_rs_test/
GitHub: https://github.com/kingledion/couch_rs_test
The way it works is this. You send the same arguments to the TestRepo::new
method that you would to set up a couch_rs Client
and Database
. TestRepo will create a database with the same name as your database except appending a random string; dbname-ab13958cf
or something like that. It also implements Drop to ensure that the database is destroyed in your CouchDB instance when TestRepo is de-allocated. This way, you can create multiple test databases instances in parallel to prevent collisions during testing, and clean them all up for parallel integration testing.
Not sure if you are interested in incorporating this into the repository here, the way couch_rs_derive is or not. If so, I'd be happy to open a PR and merge it in.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.