apache / openwhisk-package-cloudant

The Apache OpenWhisk cloudant package enables you to work with a Cloudant/CouchDB database
https://openwhisk.apache.org/
Apache License 2.0
16 stars 32 forks source link

#112 Adding feature to insert document when overwrite and putIfAbsent… #155

Closed vipulkashyap111 closed 6 years ago

vipulkashyap111 commented 6 years ago

… true

vipulkashyap111 commented 6 years ago

@jasonpet @rabbah This is for #112. Added putIfAbsent flag which if set to true along with overwrite=true will do an insertion operation if the document does not already exists(404)

rabbah commented 6 years ago

Thanks for submitting the PR. Do you have an Apache ICLA on file? https://github.com/apache/incubator-openwhisk-package-cloudant/blob/master/CONTRIBUTING.md

rabbah commented 6 years ago

It would be nice to add a unit test similar to the one here https://github.com/apache/incubator-openwhisk-package-cloudant/blob/master/tests/src/test/scala/system/packages/CloudantDatabaseActionsTests.scala#L290.

jasonpet commented 6 years ago

I can add a test and update the documentation. I will open a separate PR

vipulkashyap111 commented 6 years ago

Added a new variable to provide backward compatibility. I'll update the code as per @csantanapr review comments, do @jasonpet and @rabbah agree?

rabbah commented 6 years ago

@csantanapr I generally agree the intended behavior is to just update. The concern was about breaking existing code.

There are create and update actions which do the more conservative behavior. So we can treat this as a bug, remove the parameter and just do the update on 404. I'm OK with that too.

jasonpet commented 6 years ago

I guess only a test is needed now since we are not adding a new parameter. No annotation updates in the install script or new documentation would be necessary.

vipulkashyap111 commented 6 years ago

Removed putIfAbsent flag, document is inserted if overwrite=true and it does not already exists in the database

rabbah commented 6 years ago

@csantanapr changes updated, can you update your review?