Yesterday I was helping out Patrick Kwinten with some he had with my Cloudant Connector plugin on Slack. He asked also about the possibility to add or modify Design Documents, I found there foundation was already there.
Design Documents
Design documents can be seen as the schema in your Cloudant database, which specify what is in the view and how the ftSearch index is build.
Below is an example of a Design Document. As everything in Cloudant the syntax is JSON.
[dropshadowbox align=”none” effect=”lifted-both” width=”auto” height=”” background_color=”#ffffff” border_width=”1″ border_color=”#dddddd” ][/dropshadowbox]
New methods
As I wrote before, the foundation was already laid in the plugin, the only I had to do was to expose them to the outside world. With this new methods you can programmatically create or update Design Documents.
- connector.getDocumentConnector().createDesignDocument(final Map<String, String> updates, final String designDocument)
- connector.getDocumentConnector().updateDesignDocument(final Map<String, String> updates, final String designDocument)
updates, map of updates, where the value of the map is the javascript of the selection designDocument:
1 | updates.put( "newUpdateHandler" , "function (doc, req) { ... }" ); |
the name of the designDocument to create or update
Closing
Everything, including an updated ReadMe is in the BitBucket repository.
Thanks to Patrick for the great blogpost with boilerplate, where you can see the plugin in action.
When you need help with the plugin, let me know or reach out to me on Slack as Patrick did.
When you have feature request, please create an issue in the BitBucket Repository and I will have look if it will make it to the plugin.
Hi Frank,
thanks for the update! Nothing that keeps me from creating views except my limitations understanding map-reduce![🙂](https://s.w.org/images/core/emoji/15.0.3/svg/1f642.svg)