File tree Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
v4.2.5 (2017-xx-xx)
2
2
---------------------------
3
3
* issue #146: added ArangoCollection.exists()
4
+ * added ArangoDatabase.exists()
4
5
5
6
v4.2.4 (2017-09-04)
6
7
---------------------------
Original file line number Diff line number Diff line change @@ -781,7 +781,7 @@ public Collection<IndexEntity> getIndexes() throws ArangoDBException {
781
781
*
782
782
* @return true if the collection exists, otherwise false
783
783
*/
784
- public boolean exists () {
784
+ public boolean exists () throws ArangoDBException {
785
785
boolean exists = false ;
786
786
final Collection <CollectionEntity > collections = db ().getCollections ();
787
787
for (final CollectionEntity collection : collections ) {
Original file line number Diff line number Diff line change @@ -90,6 +90,15 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
90
90
return executor .execute (getVersionRequest (), ArangoDBVersion .class );
91
91
}
92
92
93
+ /**
94
+ * Checks whether the database exists
95
+ *
96
+ * @return true if the database exists, otherwise false
97
+ */
98
+ public boolean exists () throws ArangoDBException {
99
+ return arango ().getDatabases ().contains (name ());
100
+ }
101
+
93
102
/**
94
103
* Retrieves a list of all databases the current user can access
95
104
*
Original file line number Diff line number Diff line change @@ -104,6 +104,12 @@ public void getVersion() {
104
104
assertThat (version .getVersion (), is (notNullValue ()));
105
105
}
106
106
107
+ @ Test
108
+ public void exists () {
109
+ assertThat (db .exists (), is (true ));
110
+ assertThat (arangoDB .db ("no" ).exists (), is (false ));
111
+ }
112
+
107
113
@ Test
108
114
public void getAccessibleDatabases () {
109
115
final Collection <String > dbs = db .getAccessibleDatabases ();
You can’t perform that action at this time.
0 commit comments