https://github.com/kishieel/couchsync
CouchSync is a command-line tool that allows you to manage CouchDB design documents in a directory structure.
https://github.com/kishieel/couchsync
cli couchdb json no-sql
Last synced: 4 months ago
JSON representation
CouchSync is a command-line tool that allows you to manage CouchDB design documents in a directory structure.
- Host: GitHub
- URL: https://github.com/kishieel/couchsync
- Owner: kishieel
- License: mit
- Created: 2024-07-17T10:33:46.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-08-13T11:54:47.000Z (over 1 year ago)
- Last Synced: 2025-04-02T06:30:51.652Z (10 months ago)
- Topics: cli, couchdb, json, no-sql
- Language: Go
- Homepage:
- Size: 8.99 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Contributing: contributing.md
- License: license.md
Awesome Lists containing this project
README
# CouchSync
Managing CouchDB design documents can be a tedious task. JavaScript functions mixed with JSON can be hard to maintain and debug. For this reason, CouchSync was created. CouchSync is a command-line tool that allows you to manage CouchDB design documents in a directory structure. You can keep your functions in separate files and CouchSync will automagically parse and upload them to CouchDB as a JSON document.
### Installation
To install CouchSync you can use the following command.
```shell
wget -q https://github.com/kishieel/couchsync/raw/master/install.sh -O - | sudo bash
```
### Usage
To use CouchSync you need to prepare a directory structure that represents documents that are supposed to be uploaded to
CouchDB. The example below shows a directory structure that represents a single design document with various functions
for specified database.
```text
docs/
└─ database-name/
└─ _design/
└─ document-name/
├─ filters/
│ ├─ filter-1.js
│ └─ filter-2.js
├─ updates/
│ ├─ update-1.js
│ └─ update-2.js
├─ views/
│ ├─ view_1/
│ │ ├─ map.js
│ │ └─ reduce.js
│ └─ view_2/
│ ├─ map.js
│ └─ reduce.js
└─ validate_doc_update.js
```
With this directory structure you can use the following command to upload the documents to CouchDB.
```shell
couchsync \
--address http://localhost:5984 \
--username username \
--password password \
--source docs
```
Consequently, the document with name `_design/document-name` will be created in database with name `database-name` with
following content.
```json
{
"_id": "_design/document-name",
"filters": {
"filter-1": "function(doc, req) { ... }",
"filter-2": "function(doc, req) { ... }"
},
"updates": {
"update-1": "function(doc, req) { ... }",
"update-2": "function(doc, req) { ... }"
},
"views": {
"view_1": {
"map": "function(doc) { ... }",
"reduce": "function(keys, values, rereduce) { ... }"
},
"view_2": {
"map": "function(doc) { ... }",
"reduce": "function(keys, values, rereduce) { ... }"
}
},
"validate_doc_update": "function(newDoc, oldDoc, userCtx, secObj) { ... }"
}
```
## Contributing
Please see the [contributing.md](contributing.md) file for details on how to contribute to this project.
## License
This project is licensed under the MIT License - see the [license.md](license.md) file for details.