IBM / ibm-cloud-functions-data-processing-cloudant

Create a serverless, event-driven application with Apache OpenWhisk on IBM Cloud Functions that executes code in response to database changes from Apache CouchDB or IBM Cloudant.
https://developer.ibm.com/code/journey/respond-database-changes/
Apache License 2.0
13 stars 19 forks source link

Demonstrate pulling and saving the IBM logo as an attachment in cloudant #10

Closed jzaccone closed 7 years ago

jzaccone commented 7 years ago

Couple comments about this pull request

1) I tried to use the pre-built openwhisk actions to create the attachment, but it fails if you don't have an existing document to attach to. The openwhisk node module seems to create the document and add the attachment in a single call. 2) I randomly generate new document names to force it to create new documents, the change feed wasn't being triggered otherwise 3) I'm new to node promises, so if any reviewers can think of a better way to rewrite the write-to-cloudant.js file, refactorings are welcome!

jzaccone commented 7 years ago

Additionally... I implemented the echo by just printing out the document with the attachment name. Sample response is:

{
    "_attachments": {
        "IBM_logo6383.png": {
            "content_type": "image/png",
            "digest": "md5-APSdDZa4Kl44vuL4BQhv2g==",
            "length": 9851,
            "revpos": 1,
            "stub": true
        }
    },
    "_id": "IBM_logo6383.png",
    "_rev": "1-8a8fc33a09b0f6c8414c4bc4654bb367"
}