mirror of https://gitee.com/bigwinds/arangodb
Added a more precise information returned from gharial for collections
This commit is contained in:
parent
3a695c15fd
commit
449936b99e
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
var FoxxController = require("org/arangodb/foxx").Controller,
|
var FoxxController = require("org/arangodb/foxx").Controller,
|
||||||
controller = new FoxxController(applicationContext),
|
controller = new FoxxController(applicationContext),
|
||||||
|
cluster = require("org/arangodb/cluster"),
|
||||||
ArangoError = require("org/arangodb").ArangoError,
|
ArangoError = require("org/arangodb").ArangoError,
|
||||||
actions = require("org/arangodb/actions"),
|
actions = require("org/arangodb/actions"),
|
||||||
Model = require("org/arangodb/foxx").Model,
|
Model = require("org/arangodb/foxx").Model,
|
||||||
|
@ -43,6 +44,41 @@
|
||||||
toId = function(c, k) {
|
toId = function(c, k) {
|
||||||
return c + "/" + k;
|
return c + "/" + k;
|
||||||
},
|
},
|
||||||
|
collectionRepresentation = function(collection, showProperties, showCount, showFigures) {
|
||||||
|
var result = {};
|
||||||
|
result.id = collection._id;
|
||||||
|
result.name = collection.name();
|
||||||
|
result.isSystem = (result.name.charAt(0) === '_');
|
||||||
|
if (showProperties) {
|
||||||
|
var properties = collection.properties();
|
||||||
|
result.doCompact = properties.doCompact;
|
||||||
|
result.isVolatile = properties.isVolatile;
|
||||||
|
result.journalSize = properties.journalSize;
|
||||||
|
result.keyOptions = properties.keyOptions;
|
||||||
|
result.waitForSync = properties.waitForSync;
|
||||||
|
if (cluster.isCoordinator()) {
|
||||||
|
result.shardKeys = properties.shardKeys;
|
||||||
|
result.numberOfShards = properties.numberOfShards;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showCount) {
|
||||||
|
result.count = collection.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showFigures) {
|
||||||
|
var figures = collection.figures();
|
||||||
|
|
||||||
|
if (figures) {
|
||||||
|
result.figures = figures;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.status = collection.status();
|
||||||
|
result.type = collection.type();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
},
|
||||||
buildError = function(err, code) {
|
buildError = function(err, code) {
|
||||||
return {
|
return {
|
||||||
error: true,
|
error: true,
|
||||||
|
@ -366,9 +402,17 @@
|
||||||
controller.get("/:graph/vertex", function(req, res) {
|
controller.get("/:graph/vertex", function(req, res) {
|
||||||
var name = req.params("graph");
|
var name = req.params("graph");
|
||||||
var g = Graph._graph(name);
|
var g = Graph._graph(name);
|
||||||
setResponse(res, "collections", _.map(g._vertexCollections(), function(c) {
|
var mapFunc;
|
||||||
return c.name();
|
if (req.params("collectionObjects")) {
|
||||||
}).sort(), actions.HTTP_OK);
|
mapFunc = function(c) {
|
||||||
|
return collectionRepresentation(c, false, false, false);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
mapFunc = function(c) {
|
||||||
|
return c.name();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
setResponse(res, "collections", _.map(g._vertexCollections(), mapFunc).sort(), actions.HTTP_OK);
|
||||||
})
|
})
|
||||||
.pathParam("graph", {
|
.pathParam("graph", {
|
||||||
type: graphName
|
type: graphName
|
||||||
|
|
Loading…
Reference in New Issue