def patch_edge(name, key, data): """Partial update edge from Database""" edge = get_edge(name, key) for key in data: if key == 'from': edge['_from'] = data[key] elif key == 'to': edge['_to'] = data[key] elif key == 'properties': for idx in data[key]: edge['properties'][idx] = data[key][idx] elif key == 'properties_metadata': for idx in data[key]: edge['properties_metadata'][idx] = data[key][idx] elif key == 'name': if data[key]: edge[key] = data[key] else: edge[key] = data[key] constructor = Constructor() inst_edge = constructor.factory(kind='Edges', name=name) inst_doc = Document(inst_edge) doc = inst_doc.update_document(edge) return doc
def patch_document(name, key, data): """Partial update document from Database""" document = get_document(name, key) for key in data: if key == 'properties': for idx in data[key]: document['properties'][idx] = data[key][idx] elif key == 'properties_metadata': for idx in data[key]: document['properties_metadata'][idx] = data[key][idx] elif key == 'name': if data[key]: document[key] = data[key] else: document[key] = data[key] constructor = Constructor() inst_coll = constructor.factory(kind='Collection', name=name) inst_doc = Document(inst_coll) doc = inst_doc.update_document(document) return doc
def patch_document(name, key, data): """Partial update document from Database""" document = get_document(name, key) spec = app.config['SPECS'].get('documents_partial') util.json_validate(spec).validate(data) for key in data: if key == 'properties': for idx in data[key]: document['properties'][idx] = data[key][idx] elif key == 'properties_metadata': for idx in data[key]: document['properties_metadata'][idx] = data[key][idx] elif key == 'name': if data[key]: document[key] = data[key] else: document[key] = data[key] constructor = Constructor() inst_coll = constructor.factory(kind='Collection', name=name) inst_doc = Document(inst_coll) doc = inst_doc.update_document(document) return doc
def patch_edge(name, key, data): """Partial update edge from Database""" edge = get_edge(name, key) spec = app.config['SPECS'].get('edges_partial') util.json_validate(spec).validate(data) for key in data: if key == 'from': edge['_from'] = data[key] elif key == 'to': edge['_to'] = data[key] elif key == 'properties': for idx in data[key]: edge['properties'][idx] = data[key][idx] elif key == 'properties_metadata': for idx in data[key]: edge['properties_metadata'][idx] = data[key][idx] elif key == 'name': if data[key]: edge[key] = data[key] else: edge[key] = data[key] constructor = Constructor() inst_edge = constructor.factory(kind='Edges', name=name) inst_doc = Document(inst_edge) doc = inst_doc.update_document(edge) return doc
def update_edge(name, key, data): """Update edge from Database""" get_edge(name, key) spec = app.config['SPECS'].get('edges') util.json_validate(spec).validate(data) edge = { '_key': key, '_from': data['from'], '_to': data['to'], 'id': data['id'], 'name': data['name'], 'provider': data['provider'], 'timestamp': data['timestamp'], 'properties': data.get('properties'), 'metadata': data.get('metadata') } constructor = Constructor() inst_edge = constructor.factory(kind='Edges', name=name) inst_doc = Document(inst_edge) doc = inst_doc.update_document(edge) return doc
def update_query(key, data): """Update query in Database""" query = make_query(data) constructor = Constructor() inst_coll = constructor.factory(kind='Collection', name=app.config['META_QUERY']) inst_doc = Document(inst_coll) doc = inst_doc.update_document(query) return doc
def update_document(name, key, data): """Update document from Database""" get_document(name, key) document = { '_key': key, 'id': data['id'], 'name': data.get('name', ''), 'provider': data['provider'], 'timestamp': data['timestamp'], 'properties': data.get('properties'), 'properties_metadata': data.get('properties_metadata') } constructor = Constructor() inst_coll = constructor.factory(kind='Collection', name=name) inst_doc = Document(inst_coll) doc = inst_doc.update_document(document) return doc
def update_edge(name, key, data): """Update edge from Database""" get_edge(name, key) edge = { '_key': key, '_from': data['from'], '_to': data['to'], 'id': data['id'], 'name': data.get('name', ''), 'provider': data['provider'], 'timestamp': data['timestamp'], 'properties': data.get('properties'), 'properties_metadata': data.get('properties_metadata') } constructor = Constructor() inst_edge = constructor.factory(kind='Edges', name=name) inst_doc = Document(inst_edge) doc = inst_doc.update_document(edge) return doc
def update_document(name, key, data): """Update document from Database""" get_document(name, key) spec = app.config['SPECS'].get('documents') util.json_validate(spec).validate(data) document = { '_key': key, 'id': data['id'], 'name': data['name'], 'provider': data['provider'], 'timestamp': data['timestamp'], 'properties': data.get('properties'), 'metadata': data.get('metadata') } constructor = Constructor() inst_coll = constructor.factory(kind='Collection', name=name) inst_doc = Document(inst_coll) doc = inst_doc.update_document(document) return doc