apache / apache/couchdb

Additional Mango-based update handler / VDU functionality

Open
#1,554 27 comments 0 reactions 1 assignee Claimed by @wohali View on GitHub
mango roadmap
Dominant language
Erlang
Stars
7k
Forks
1.1k
Avg merge
1d 16h
Merged PRs (30d)
9

Description

This ticket is intended to gather ideas for what other sorts of update handler / VDU functionality we could add to Mango to provide a declarative replacement for JS-based update handlers and VDUs. This is intended as a "blue-sky" ticket to gather ideas that can be implemented simply in a declarative fashion.

From #1534, I wrote:

> There are other proposals to provide similar/useful functionality (#1532, #1533, #1498) if the operator decides to run without a JS engine (#1513), plus I suspect there are thoughts about doing Mango-based update functionality to filter fields, as well as apply database schema enforcement (type and format checking) in a declarative fashion for a NoJS mode. Could your embedded RasPi update function be written declaratively? I assume you're adding info such as incoming IP address, central timestamp, etc. which I could see being done automatically quite easily. This is a use case we can accelerate without the use of JS readily; we just need to agree on an API and how to write it down in a JSON blob.

Extracting:

* Add datetime stamp (#1533)
* Add IP address from incoming host, or other fields from the `req` object
* Add additional content based on fields in the `req` object
* Perhaps a lookup table that maps a `req` field value to a key:value pair (or JSON Patch) to insert?
* Filter out (blacklist) or only allow (whitelist) certain fields (lists) - this is partial JSON schema support
* Type-checking (field `type` is string, field `date` is ISO datetime|UNIX epoch, _etc._)
* Field validation (format-checking, i.e. string must match a regex like `"$###.##"` or an integer must be within a certain range)
* Consider using output of another Mango index/query for validating a field? For instance, a Mango query of documents that are of type `source` and extracting the field `ip_address`, then only allowing documents to come through that have a matching `req.ip_address` (for example).
* Same as above, but to implement the lookup table. Example: look up source's IP address, auto-add name of sensor which is in the first document that matches in the Mango index

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.