1
0
Fork 0
arangodb/Documentation/DocuBlocks/Rest/Documents/REST_DOCUMENT_READ_ALL.md

2.7 KiB

//////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock REST_DOCUMENT_READ_ALL /// @brief reads all documents from collection /// /// @RESTHEADER{GET /_api/document,Read all documents} /// /// @RESTQUERYPARAMETERS /// /// @RESTQUERYPARAM{collection,string,required} /// The name of the collection. /// /// @RESTQUERYPARAM{type,string,optional} /// The type of the result. The following values are allowed: /// /// - id: returns an array of document ids (_id attributes) /// - key: returns an array of document keys (_key attributes) /// - path: returns an array of document URI paths. This is the default. /// /// @RESTDESCRIPTION /// Returns an array of all keys, ids, or URI paths for all documents in the /// collection identified by collection. The type of the result array is /// determined by the type attribute. /// /// Note that the results have no defined order and thus the order should /// not be relied on. /// /// @RESTRETURNCODES /// /// @RESTRETURNCODE{200} /// All went good. /// /// @RESTRETURNCODE{404} /// The collection does not exist. /// /// @EXAMPLES /// /// Return all document paths /// /// @EXAMPLE_ARANGOSH_RUN{RestDocumentHandlerReadDocumentAllPath} /// var cn = "products"; /// db._drop(cn); /// db._create(cn); /// /// db.products.save({"hello1":"world1"}); /// db.products.save({"hello2":"world1"}); /// db.products.save({"hello3":"world1"}); /// var url = "/_api/document/?collection=" + cn; /// /// var response = logCurlRequest('GET', url); /// /// assert(response.code === 200); /// /// logJsonResponse(response); /// ~ db._drop(cn); /// @END_EXAMPLE_ARANGOSH_RUN /// /// Return all document keys /// /// @EXAMPLE_ARANGOSH_RUN{RestDocumentHandlerReadDocumentAllKey} /// var cn = "products"; /// db._drop(cn); /// db._create(cn); /// /// db.products.save({"hello1":"world1"}); /// db.products.save({"hello2":"world1"}); /// db.products.save({"hello3":"world1"}); /// var url = "/_api/document/?collection=" + cn + "&type=key"; /// /// var response = logCurlRequest('GET', url); /// /// assert(response.code === 200); /// /// logJsonResponse(response); /// ~ db._drop(cn); /// @END_EXAMPLE_ARANGOSH_RUN /// /// Collection does not exist /// /// @EXAMPLE_ARANGOSH_RUN{RestDocumentHandlerReadDocumentAllCollectionDoesNotExist} /// var cn = "doesnotexist"; /// db._drop(cn); /// var url = "/_api/document/?collection=" + cn; /// /// var response = logCurlRequest('GET', url); /// /// assert(response.code === 404); /// /// logJsonResponse(response); /// @END_EXAMPLE_ARANGOSH_RUN /// @endDocuBlock ////////////////////////////////////////////////////////////////////////////////