1
0
Fork 0

changed structure of response to GET /_api/collection

This commit is contained in:
Jan Steemann 2016-05-19 17:56:15 +02:00
parent 70d60e623e
commit e5ceaf85b4
4 changed files with 13 additions and 41 deletions

View File

@ -36,10 +36,7 @@ describe ArangoDB do
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(200)
collections = doc.parsed_response['collections']
names = doc.parsed_response['names']
collections.length.should eq(names.length)
collections = doc.parsed_response["result"];
total = 0
realCollections = [ ]
@ -50,21 +47,8 @@ describe ArangoDB do
total = total + 1
}
realNames = { }
names.each do |name, collection|
if [ "units", "employees", "locations" ].include? name
realNames[name] = collection
end
end
for collection in realCollections do
realNames[collection['name']].should eq(collection)
end
realCollections.length.should eq(3)
realNames.length.should eq(3)
total.should be > 3
end
it "returns all collections, exclude system collections" do
@ -76,10 +60,7 @@ describe ArangoDB do
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(200)
collections = doc.parsed_response['collections']
names = doc.parsed_response['names']
collections.length.should eq(names.length)
collections = doc.parsed_response["result"]
realCollections = [ ]
total = 0
@ -90,16 +71,7 @@ describe ArangoDB do
total = total + 1
}
realNames = { }
names.each do |name, collection|
if [ "units", "employees", "locations" ].include? name
realNames[name] = collection
end
end
realCollections.length.should eq(3)
realNames.length.should eq(3)
total.should >= 3
end

View File

@ -943,9 +943,14 @@ static int LoadCollectionVocBase(TRI_vocbase_t* vocbase,
// status while it is loading (loading may take a long time because of
// disk activity, index creation etc.)
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
bool ignoreDatafileErrors = false;
if (DatabaseFeature::DATABASE != nullptr) {
ignoreDatafileErrors = DatabaseFeature::DATABASE->ignoreDatafileErrors();
}
TRI_document_collection_t* document =
TRI_OpenDocumentCollection(vocbase, collection, DatabaseFeature::DATABASE->ignoreDatafileErrors());
TRI_OpenDocumentCollection(vocbase, collection, ignoreDatafileErrors);
// lock again the adjust the status
TRI_EVENTUAL_WRITE_LOCK_STATUS_VOCBASE_COL(collection);

View File

@ -236,9 +236,6 @@ function post_api_collection (req, res) {
////////////////////////////////////////////////////////////////////////////////
function get_api_collections (req, res) {
var i;
var list = [];
var names = {};
var excludeSystem;
var collections = arangodb.db._collections();
@ -250,20 +247,18 @@ function get_api_collections (req, res) {
}
}
for (i = 0; i < collections.length; ++i) {
var list = [];
for (var i = 0; i < collections.length; ++i) {
var collection = collections[i];
var rep = collectionRepresentation(collection);
// include system collections or exclude them?
if (! excludeSystem || rep.name.substr(0, 1) !== '_') {
list.push(rep);
names[rep.name] = rep;
}
}
var result = { collections : list, names : names };
actions.resultOk(req, res, actions.HTTP_OK, result);
actions.resultOk(req, res, actions.HTTP_OK, { result : list });
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -247,8 +247,8 @@ ArangoDatabase.prototype._collections = function () {
arangosh.checkRequestResult(requestResult);
if (requestResult.collections !== undefined) {
var collections = requestResult.collections;
if (requestResult.result !== undefined) {
var collections = requestResult.result;
var result = [];
var i;