/** * Delete a record from the database. * * @param table * The name of the table * @param key * The record key of the record to delete. * @return Zero on success, a non-zero error code on error. See the * {@link DB} class's description for a discussion of error codes. */ @Override public Status delete(String table, String key) { try { arangoDB.db(databaseName).collection(table).deleteDocument(key); return Status.OK; } catch (ArangoDBException e) { logger.error("Exception while trying delete {} {} with ex {}", table, key, e.toString()); } return Status.ERROR; }
@Override public <K> void remove(K key) throws NullPointerException { arangoDB.db(bucketName).collection(namespace).deleteDocument(key.toString()); }
@Override public <K, V> void put(K key, V value) throws NullPointerException { Objects.requireNonNull(key, "Key is required"); Objects.requireNonNull(value, "value is required"); BaseDocument baseDocument = new BaseDocument(); baseDocument.setKey(key.toString()); baseDocument.addAttribute(VALUE, JSONB.toJson(value)); if (arangoDB.db(bucketName).collection(namespace).documentExists(key.toString())) { arangoDB.db(bucketName).collection(namespace).deleteDocument(key.toString()); } arangoDB.db(bucketName).collection(namespace) .insertDocument(baseDocument); }
@Override public DocumentEntity delete(final Object id, final Class<?> entityClass, final DocumentDeleteOptions options) throws DataAccessException { potentiallyEmitEvent(new BeforeDeleteEvent<>(id, entityClass)); final DocumentEntity result; try { result = _collection(entityClass, id).deleteDocument(determineDocumentKeyFromId(id), entityClass, options); } catch (final ArangoDBException e) { throw translateExceptionIfPossible(e); } potentiallyEmitEvent(new AfterDeleteEvent<>(id, entityClass)); return result; }
@Override public DocumentEntity delete(final Object id, final Class<?> entityClass, final DocumentDeleteOptions options) throws DataAccessException { potentiallyEmitEvent(new BeforeDeleteEvent<>(id, entityClass)); final DocumentEntity result; try { result = _collection(entityClass, id).deleteDocument(determineDocumentKeyFromId(id), entityClass, options); } catch (final ArangoDBException e) { throw translateExceptionIfPossible(e); } potentiallyEmitEvent(new AfterDeleteEvent<>(id, entityClass)); return result; }