I want to add a timestamp to every document added to Cloudant / CouchDB. My client is a low power IoT device that doesn't know the current time (NTP operation costs too much power).
From what I have read I can use a design document for this, but the client has to trigger this manually after inserting the document. This will be too power-intensive for the client as it has to do two HTTP requests instead of one.
Is there any way to facilitate this?
Creating a design document is the best solution in your case.
You need to define an update function (see this) for full documentation.
In this update function, you will be able to modify the document passed to this function to set a timestamp as it's _id.
You don't need to create the document before calling this update handler. You can simply send a request with the document inside the request body.