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 11v4.2.5 (2017-xx-xx)
22---------------------------
33* issue #146: added ArangoCollection.exists()
4+ * added ArangoDatabase.exists()
45
56v4.2.4 (2017-09-04)
67---------------------------
Original file line number Diff line number Diff line change @@ -781,7 +781,7 @@ public Collection<IndexEntity> getIndexes() throws ArangoDBException {
781781 *
782782 * @return true if the collection exists, otherwise false
783783 */
784- public boolean exists () {
784+ public boolean exists () throws ArangoDBException {
785785 boolean exists = false ;
786786 final Collection <CollectionEntity > collections = db ().getCollections ();
787787 for (final CollectionEntity collection : collections ) {
Original file line number Diff line number Diff line change @@ -90,6 +90,15 @@ public ArangoDBVersion getVersion() throws ArangoDBException {
9090 return executor .execute (getVersionRequest (), ArangoDBVersion .class );
9191 }
9292
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+
93102 /**
94103 * Retrieves a list of all databases the current user can access
95104 *
Original file line number Diff line number Diff line change @@ -104,6 +104,12 @@ public void getVersion() {
104104 assertThat (version .getVersion (), is (notNullValue ()));
105105 }
106106
107+ @ Test
108+ public void exists () {
109+ assertThat (db .exists (), is (true ));
110+ assertThat (arangoDB .db ("no" ).exists (), is (false ));
111+ }
112+
107113 @ Test
108114 public void getAccessibleDatabases () {
109115 final Collection <String > dbs = db .getAccessibleDatabases ();
You can’t perform that action at this time.
0 commit comments