mirror of https://gitee.com/bigwinds/arangodb
changed structure of response to GET /_api/collection
This commit is contained in:
parent
70d60e623e
commit
e5ceaf85b4
|
@ -36,10 +36,7 @@ describe ArangoDB do
|
||||||
doc.parsed_response['error'].should eq(false)
|
doc.parsed_response['error'].should eq(false)
|
||||||
doc.parsed_response['code'].should eq(200)
|
doc.parsed_response['code'].should eq(200)
|
||||||
|
|
||||||
collections = doc.parsed_response['collections']
|
collections = doc.parsed_response["result"];
|
||||||
names = doc.parsed_response['names']
|
|
||||||
|
|
||||||
collections.length.should eq(names.length)
|
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
realCollections = [ ]
|
realCollections = [ ]
|
||||||
|
@ -50,21 +47,8 @@ describe ArangoDB do
|
||||||
total = total + 1
|
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)
|
realCollections.length.should eq(3)
|
||||||
realNames.length.should eq(3)
|
|
||||||
total.should be > 3
|
total.should be > 3
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns all collections, exclude system collections" do
|
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['error'].should eq(false)
|
||||||
doc.parsed_response['code'].should eq(200)
|
doc.parsed_response['code'].should eq(200)
|
||||||
|
|
||||||
collections = doc.parsed_response['collections']
|
collections = doc.parsed_response["result"]
|
||||||
names = doc.parsed_response['names']
|
|
||||||
collections.length.should eq(names.length)
|
|
||||||
|
|
||||||
realCollections = [ ]
|
realCollections = [ ]
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
|
@ -90,16 +71,7 @@ describe ArangoDB do
|
||||||
total = total + 1
|
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)
|
realCollections.length.should eq(3)
|
||||||
realNames.length.should eq(3)
|
|
||||||
|
|
||||||
total.should >= 3
|
total.should >= 3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -943,9 +943,14 @@ static int LoadCollectionVocBase(TRI_vocbase_t* vocbase,
|
||||||
// status while it is loading (loading may take a long time because of
|
// status while it is loading (loading may take a long time because of
|
||||||
// disk activity, index creation etc.)
|
// disk activity, index creation etc.)
|
||||||
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
|
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
|
||||||
|
|
||||||
|
bool ignoreDatafileErrors = false;
|
||||||
|
if (DatabaseFeature::DATABASE != nullptr) {
|
||||||
|
ignoreDatafileErrors = DatabaseFeature::DATABASE->ignoreDatafileErrors();
|
||||||
|
}
|
||||||
|
|
||||||
TRI_document_collection_t* document =
|
TRI_document_collection_t* document =
|
||||||
TRI_OpenDocumentCollection(vocbase, collection, DatabaseFeature::DATABASE->ignoreDatafileErrors());
|
TRI_OpenDocumentCollection(vocbase, collection, ignoreDatafileErrors);
|
||||||
|
|
||||||
// lock again the adjust the status
|
// lock again the adjust the status
|
||||||
TRI_EVENTUAL_WRITE_LOCK_STATUS_VOCBASE_COL(collection);
|
TRI_EVENTUAL_WRITE_LOCK_STATUS_VOCBASE_COL(collection);
|
||||||
|
|
|
@ -236,9 +236,6 @@ function post_api_collection (req, res) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function get_api_collections (req, res) {
|
function get_api_collections (req, res) {
|
||||||
var i;
|
|
||||||
var list = [];
|
|
||||||
var names = {};
|
|
||||||
var excludeSystem;
|
var excludeSystem;
|
||||||
var collections = arangodb.db._collections();
|
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 collection = collections[i];
|
||||||
var rep = collectionRepresentation(collection);
|
var rep = collectionRepresentation(collection);
|
||||||
|
|
||||||
// include system collections or exclude them?
|
// include system collections or exclude them?
|
||||||
if (! excludeSystem || rep.name.substr(0, 1) !== '_') {
|
if (! excludeSystem || rep.name.substr(0, 1) !== '_') {
|
||||||
list.push(rep);
|
list.push(rep);
|
||||||
names[rep.name] = rep;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = { collections : list, names : names };
|
actions.resultOk(req, res, actions.HTTP_OK, { result : list });
|
||||||
|
|
||||||
actions.resultOk(req, res, actions.HTTP_OK, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -247,8 +247,8 @@ ArangoDatabase.prototype._collections = function () {
|
||||||
|
|
||||||
arangosh.checkRequestResult(requestResult);
|
arangosh.checkRequestResult(requestResult);
|
||||||
|
|
||||||
if (requestResult.collections !== undefined) {
|
if (requestResult.result !== undefined) {
|
||||||
var collections = requestResult.collections;
|
var collections = requestResult.result;
|
||||||
var result = [];
|
var result = [];
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue