@@ -1734,6 +1734,97 @@ public List<String> getDocuments(String collectionName, boolean handleConvert) t
1734
1734
return documentDriver .getDocuments (getDefaultDatabase (), collectionName , handleConvert );
1735
1735
}
1736
1736
1737
+ /**
1738
+ * The exists method determines whether a document exists given its
1739
+ * identifier. Instead of returning the found document or an error, this
1740
+ * method will return either true or false. It can thus be used for easy
1741
+ * existence checks.
1742
+ *
1743
+ * @param collectionId
1744
+ * The collection id.
1745
+ * @param documentId
1746
+ * The document id
1747
+ * @return true, if the document exists
1748
+ * @throws ArangoException
1749
+ */
1750
+ public boolean exists (long collectionId , long documentId ) throws ArangoException {
1751
+ return exists (createDocumentHandle (collectionId , String .valueOf (documentId )));
1752
+ }
1753
+
1754
+ /**
1755
+ * The exists method determines whether a document exists given its
1756
+ * identifier. Instead of returning the found document or an error, this
1757
+ * method will return either true or false. It can thus be used for easy
1758
+ * existence checks.
1759
+ *
1760
+ * @param collectionName
1761
+ * The collection name.
1762
+ * @param documentId
1763
+ * The document id
1764
+ * @return true, if the document exists
1765
+ * @throws ArangoException
1766
+ */
1767
+ public boolean exists (String collectionName , long documentId ) throws ArangoException {
1768
+ return exists (createDocumentHandle (collectionName , String .valueOf (documentId )));
1769
+ }
1770
+
1771
+ /**
1772
+ * The exists method determines whether a document exists given its
1773
+ * identifier. Instead of returning the found document or an error, this
1774
+ * method will return either true or false. It can thus be used for easy
1775
+ * existence checks.
1776
+ *
1777
+ * @param collectionId
1778
+ * The collection id.
1779
+ * @param documentKey
1780
+ * The document key
1781
+ * @return true, if the document exists
1782
+ * @throws ArangoException
1783
+ */
1784
+ public boolean exists (long collectionId , String documentKey ) throws ArangoException {
1785
+ return exists (createDocumentHandle (collectionId , documentKey ));
1786
+ }
1787
+
1788
+ /**
1789
+ * The exists method determines whether a document exists given its
1790
+ * identifier. Instead of returning the found document or an error, this
1791
+ * method will return either true or false. It can thus be used for easy
1792
+ * existence checks.
1793
+ *
1794
+ * @param collectionName
1795
+ * The collection name.
1796
+ * @param documentKey
1797
+ * The document key
1798
+ * @return true, if the document exists
1799
+ * @throws ArangoException
1800
+ */
1801
+ public boolean exists (String collectionName , String documentKey ) throws ArangoException {
1802
+ return exists (createDocumentHandle (collectionName , documentKey ));
1803
+ }
1804
+
1805
+ /**
1806
+ * The exists method determines whether a document exists given its
1807
+ * identifier. Instead of returning the found document or an error, this
1808
+ * method will return either true or false. It can thus be used for easy
1809
+ * existence checks.
1810
+ *
1811
+ * @param documentHandle
1812
+ * The document handle
1813
+ * @return true, if the document exists
1814
+ * @throws ArangoException
1815
+ */
1816
+ public boolean exists (String documentHandle ) throws ArangoException {
1817
+ try {
1818
+ documentDriver .checkDocument (getDefaultDatabase (), documentHandle );
1819
+ } catch (ArangoException e ) {
1820
+ if (e .getCode () == ErrorNums .ERROR_HTTP_NOT_FOUND ) {
1821
+ return false ;
1822
+ }
1823
+ throw e ;
1824
+ }
1825
+ return true ;
1826
+ }
1827
+
1737
1828
/**
1738
1829
* This method returns the current revision of a document.
1739
1830
*
0 commit comments