def test_eventing_processes_mutation_when_xattrs_is_updated(self): url = 'couchbase://{ip}/{name}'.format(ip=self.master.ip, name=self.src_bucket_name) bucket = Bucket(url, username="******", password="******") for docid in ['customer123', 'customer1234', 'customer12345']: bucket.upsert(docid, {}) body = self.create_save_function_body(self.function_name, self.handler_code, dcp_stream_boundary="from_now") # deploy eventing function self.deploy_function(body) # update multiple xattrs and update the documents for docid in ['customer123', 'customer1234', 'customer12345']: bucket.mutate_in(docid, SD.upsert('my1', {'value': 1}, xattr=True)) bucket.mutate_in(docid, SD.upsert('my2', {'value': 2}, xattr=True)) bucket.mutate_in(docid, SD.upsert('fax', '775-867-5309')) self.verify_eventing_results(self.function_name, 3, skip_stats_validation=True) # add new multiple xattrs , delete old xattrs and delete the documents for docid in ['customer123', 'customer1234', 'customer12345']: bucket.mutate_in(docid, SD.upsert('my3', {'value': 3}, xattr=True)) bucket.mutate_in(docid, SD.upsert('my4', {'value': 4}, xattr=True)) bucket.mutate_in(docid, SD.remove('my3', xattr=True)) bucket.mutate_in(docid, SD.remove('my4', xattr=True)) bucket.remove(docid) self.verify_eventing_results(self.function_name, 0, skip_stats_validation=True) self.undeploy_and_delete_function(body)
def delete(self, client, key = '', path = '', xattr=None): try: if self.is_sdk_client: # xattr not supported? client.mutate_in(key, SD.remove(path, xattr=xattr)) else: client.delete_sd(key, path) except Exception as e: self.log.info(e) self.fail("Unable to delete in key {0} for path {1} after {2} tries".format(key, path, 1))
def delete(self, client, key='', path='', value=None): try: if self.verbose_func_usage: self.log.info(" delete ----> {0} ".format(path)) if self.use_sdk_client: client.mutate_in(key, SD.remove(path, xattr=self.xattr)) else: client.delete_sd(key, path) except Exception: raise
def offeringDELETE(quarter, courseNum, sectionId): # TODO: make redis call sec = ("." + sectionId) if sectionId else '' offering_bucket.mutate_in(quarter, subdoc.remove(courseNum + sec)) return make_response("Deleted", 200)
def subdocument_remove(bucket, document_id, path): rv = bucket.mutate_in( document_id, SD.remove(path) ) # don't convert the dict to json. the method will automatically return rv[0]
"customer123", [SD.insert("purchases.pending", [42, True, "None"])]) try: collection.mutate_in( "customer123", [ SD.insert( "purchases.complete", [42, True, "None"])]) except PathExistsException: print("Path exists, cannot use insert.") # end::mutate_in_insert[] # tag::combine_dict[] collection.mutate_in( "customer123", (SD.remove("addresses.billing"), SD.replace( "email", "*****@*****.**"))) # end::combine_dict[] # NOTE: the mutate_in() operation expects a tuple or list # tag::array_append[] collection.mutate_in( "customer123", (SD.array_append( "purchases.complete", 777),)) # purchases.complete is now [339, 976, 442, 666, 777] # end::array_append[] # tag::array_prepend[]