Created
January 4, 2024 22:56
-
-
Save nickva/e550fb2d4cb35eb9e18323560f6c308a to your computer and use it in GitHub Desktop.
Various changes feed parameters for Apache CouchDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
http -q delete $DB/db | |
http -q put $DB/db | |
http post $DB/db/_bulk_docs new_edits:='false' docs:='[{"_id":"d1", "_revisions":{"start":2, "ids":["x", "z"]}, "data":1}, {"_id":"d1", "data":2, "_revisions":{"start":2, "ids":["y", "z"]}}, {"_id":"d1", "data":3, "_deleted":true, "_revisions":{"start":2, "ids":["w", "z"]}}]' | |
http -q put $DB/db/d1/att2y'?rev=2-y' data=2y | |
http -q put $DB/db/d1/att2x'?rev=2-x' data=2x | |
echo "Without a filter with atts" | |
http -b get $DB/db/_changes'?style=all_docs&include_docs=true&attachments=true' | |
echo "Without a filter with atts encoding info" | |
http -b get $DB/db/_changes'?style=all_docs&include_docs=true&attachments=true&att_encoding_info=true' | |
echo "Without a filter with atts encoding info conflicts=true" | |
http -b get $DB/db/_changes'?style=all_docs&include_docs=true&attachments=true&att_encoding_info=true&conflicts=true' | |
echo "With a selector data=2" | |
http -b post $DB/db/_changes'?style=all_docs&include_docs=true&filter=_selector&att_encoding_info=true' selector:='{"data": 2}' | |
echo "With a selector data=2 conflicts=true" | |
http -b post $DB/db/_changes'?style=all_docs&include_docs=true&filter=_selector&att_encoding_info=true&conflicts=true' selector:='{"data": 2}' | |
echo "With JS filter data=2" | |
http -q put $DB/db/_design/f filters:='{"f1": "function(doc, req) {return (doc.data == 1)}", "f2": "function(doc, req) { return (doc.data == 2)}"}' | |
http -b get $DB/db/_changes'?style=all_docs&include_docs=true&filter=f/f2&att_encoding_info=true' | |
echo "With JS filter data=2 conflicts=true" | |
http -q put $DB/db/_design/f filters:='{"f1": "function(doc, req) {return (doc.data == 1)}", "f2": "function(doc, req) { return (doc.data == 2)}"}' | |
http -b get $DB/db/_changes'?style=all_docs&include_docs=true&filter=f/f2&att_encoding_info=true&conflicts=true' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment