Exemplo n.º 1
0
 def insert_document(self, key, document):
     insert_success = False
     try:
         self.cb.insert(
             JsonDocument.create(key, JsonObject.fromJson(document)))
         insert_success = True
     except:
         pass
     return insert_success
Exemplo n.º 2
0
 def __translate_to_json_document(self, key, value, ttl=0):
     try:
         if type(value) != dict:
             value = json.loads(value)
         js = JsonObject.create()
         for field, val in value.items():
             js.put(field, val)
         doc = JsonDocument.create(key, ttl, js)
         return doc
     except DocumentNotJsonException as e:
         return StringDocument.create(key, str(value))
     except Exception as e:
         return StringDocument.create(key, str(value))
     except:
         pass
     return StringDocument.create(key, str(value))
Exemplo n.º 3
0
 def insert_json_documents(self, key_prefix, documents):
     for index, data in enumerate(documents):
         self.cb.insert(
             JsonDocument.create(key_prefix + str(index),
                                 JsonObject.fromJson(data)))
Exemplo n.º 4
0
 def insert_custom_json_documents(self, key_prefix, documents):
     for index, data in enumerate(documents):
         self.cb.insert(
             JsonDocument.create(key_prefix + str(index),
                                 JsonObject.create().put("content", data)))