File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ v4.2.5 (2017-xx-xx)
2
+ ---------------------------
3
+ * issue #146: added ArangoCollection.exists()
4
+
1
5
v4.2.4 (2017-09-04)
2
6
---------------------------
3
7
* fixed ArangoDatabase.transaction(): ignore null result
Original file line number Diff line number Diff line change @@ -776,6 +776,23 @@ public Collection<IndexEntity> getIndexes() throws ArangoDBException {
776
776
return executor .execute (getIndexesRequest (), getIndexesResponseDeserializer ());
777
777
}
778
778
779
+ /**
780
+ * Checks whether the collection exists
781
+ *
782
+ * @return true if the collection exists, otherwise false
783
+ */
784
+ public boolean exists () {
785
+ boolean exists = false ;
786
+ final Collection <CollectionEntity > collections = db ().getCollections ();
787
+ for (final CollectionEntity collection : collections ) {
788
+ if (collection .getName ().equals (name ())) {
789
+ exists = true ;
790
+ break ;
791
+ }
792
+ }
793
+ return exists ;
794
+ }
795
+
779
796
/**
780
797
* Removes all documents from the collection, but leaves the indexes intact
781
798
*
Original file line number Diff line number Diff line change @@ -954,6 +954,12 @@ public void getEdgeIndex() {
954
954
}
955
955
}
956
956
957
+ @ Test
958
+ public void exists () {
959
+ assertThat (db .collection (COLLECTION_NAME ).exists (), is (true ));
960
+ assertThat (db .collection (COLLECTION_NAME + "no" ).exists (), is (false ));
961
+ }
962
+
957
963
@ Test
958
964
public void truncate () {
959
965
final BaseDocument doc = new BaseDocument ();
You can’t perform that action at this time.
0 commit comments