beppu / anyevent-couchdb Goto Github PK
View Code? Open in Web Editor NEWa non-blocking CouchDB client for Perl based on jquery.couch.js
Home Page: http://github.com/beppu/anyevent-couchdb/tree/master
a non-blocking CouchDB client for Perl based on jquery.couch.js
Home Page: http://github.com/beppu/anyevent-couchdb/tree/master
A PUT request to an existing document with the request body containing "_deleted": true
returns 200 on success, not 201, causing the script to incorrectly carp.
If you save a document with an inline attachment, the changes from 1.26 lib/AnyEvent/CouchDB/Database.pm save_doc $_attachments subroutine delete the attachment 'data' property and replace it with length, revpos, and stub:true.
Since revpos is extracted with a regex, it's in string context. The next time you save the document, the revpos in the attachment stub is sent to the server as a string. Unfortunately, on couchdb 1.1.1, this causes an error 412 since CouchDB expects revpos to be a number, and gives a {"error":"missing_stub","reason":"id:test, name:test3.gif"}
response.
e.g. with a document with a 'test3.gif' attachment uploaded at revpos 2, curl -X PUT localhost:5984/database/test -d '{"_id":"test", "_rev":"14-47afaef5d143f63a9f9104e90c1ce71a", "_attachments":{"test3.gif":{"revpos":"2","length":6,"stub":true}}}'
fails, but curl -X PUT localhost:5984/database/test -d '{"_id":"test", "_rev":"14-47afaef5d143f63a9f9104e90c1ce71a", "_attachments":{"test3.gif":{"revpos":2,"length":6,"stub":true}}}'
works.
One possible solution is to use revpos in a numeric context before saving so it'll be serialized as a number, the other solution is to just delete it before sending since CouchDB seems happy to accept {stub:true}.
Incidentally, CouchDB 1.1.1 adds an MD5 'digest' field to the returned stub; it can be left out when saving the document though as long as {stub:true} is present.
At the moment you can do the following, which will not work as the JSON parser is given the raw multi-part response.
$db->open_doc($id, {'open_revs' => 'all'})->recv;
Presumably this should return an array of all the versions (and probably ignore any attachments in the response).
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.