mirror of https://gitee.com/bigwinds/arangodb
_listDatabases() => _databases()
This commit is contained in:
parent
d055f10b3b
commit
4d13e8fb1b
|
@ -103,7 +103,7 @@ shell window):
|
|||
```js
|
||||
$ arangosh --server.endpoint tcp://localhost:8530
|
||||
[... some output omitted]
|
||||
arangosh [_system]> db._listDatabases();
|
||||
arangosh [_system]> db._databases();
|
||||
[
|
||||
"_system"
|
||||
]
|
||||
|
|
|
@ -107,7 +107,7 @@ endpoint data.
|
|||
|
||||
|
||||
return the list of all existing databases
|
||||
`db._listDatabases()`
|
||||
`db._databases()`
|
||||
|
||||
Returns the list of all databases. This method can only be used from within
|
||||
the *_system* database.
|
||||
|
|
|
@ -61,7 +61,7 @@ advantage that you can use autocompletion.
|
|||
> db._query(<query>).toArray() execute an AQL query
|
||||
> db._useDatabase(<name>) switch database
|
||||
> db._createDatabase(<name>) create a new database
|
||||
> db._listDatabases() list existing databases
|
||||
> db._databases() list existing databases
|
||||
> help show help pages
|
||||
> exit
|
||||
arangosh>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
|
||||
@brief return the list of all existing databases
|
||||
`db._listDatabases()`
|
||||
`db._databases()`
|
||||
|
||||
Returns the list of all databases. This method can only be used from within
|
||||
the *_system* database.
|
||||
|
|
|
@ -370,7 +370,7 @@ bool ClusterInfo::doesDatabaseExist(DatabaseID const& databaseID, bool reload) {
|
|||
/// @brief get list of databases in the cluster
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::vector<DatabaseID> ClusterInfo::listDatabases(bool reload) {
|
||||
std::vector<DatabaseID> ClusterInfo::databases(bool reload) {
|
||||
std::vector<DatabaseID> result;
|
||||
|
||||
if (reload || !_planProt.isValid ||
|
||||
|
|
|
@ -600,7 +600,7 @@ class ClusterInfo {
|
|||
/// @brief get list of databases in the cluster
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::vector<DatabaseID> listDatabases(bool = false);
|
||||
std::vector<DatabaseID> databases(bool = false);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief (re-)load the information about our plan
|
||||
|
|
|
@ -360,7 +360,7 @@ void HeartbeatThread::runCoordinator() {
|
|||
if (userVersion > 0 && userVersion != oldUserVersion) {
|
||||
// reload user cache for all databases
|
||||
std::vector<DatabaseID> dbs =
|
||||
ClusterInfo::instance()->listDatabases(true);
|
||||
ClusterInfo::instance()->databases(true);
|
||||
std::vector<DatabaseID>::iterator i;
|
||||
bool allOK = true;
|
||||
for (i = dbs.begin(); i != dbs.end(); ++i) {
|
||||
|
|
|
@ -612,15 +612,15 @@ static void JS_DoesDatabaseExistClusterInfo(
|
|||
/// @brief get the list of databases in the cluster
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void JS_ListDatabases(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||
static void JS_Databases(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||
TRI_V8_TRY_CATCH_BEGIN(isolate);
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
if (args.Length() != 0) {
|
||||
TRI_V8_THROW_EXCEPTION_USAGE("listDatabases()");
|
||||
TRI_V8_THROW_EXCEPTION_USAGE("databases()");
|
||||
}
|
||||
|
||||
std::vector<DatabaseID> res = ClusterInfo::instance()->listDatabases(true);
|
||||
std::vector<DatabaseID> res = ClusterInfo::instance()->databases(true);
|
||||
v8::Handle<v8::Array> a = v8::Array::New(isolate, (int)res.size());
|
||||
std::vector<DatabaseID>::iterator it;
|
||||
int count = 0;
|
||||
|
@ -1988,8 +1988,8 @@ void TRI_InitV8Cluster(v8::Isolate* isolate, v8::Handle<v8::Context> context) {
|
|||
|
||||
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("doesDatabaseExist"),
|
||||
JS_DoesDatabaseExistClusterInfo);
|
||||
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("listDatabases"),
|
||||
JS_ListDatabases);
|
||||
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("databases"),
|
||||
JS_Databases);
|
||||
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("flush"),
|
||||
JS_FlushClusterInfo, true);
|
||||
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING("getCollectionInfo"),
|
||||
|
|
|
@ -2783,7 +2783,7 @@ static void JS_CompletionsVocbase(
|
|||
result->Set(j++, TRI_V8_ASCII_STRING("_exists()"));
|
||||
result->Set(j++, TRI_V8_ASCII_STRING("_id"));
|
||||
result->Set(j++, TRI_V8_ASCII_STRING("_isSystem()"));
|
||||
result->Set(j++, TRI_V8_ASCII_STRING("_listDatabases()"));
|
||||
result->Set(j++, TRI_V8_ASCII_STRING("_databases()"));
|
||||
result->Set(j++, TRI_V8_ASCII_STRING("_name()"));
|
||||
result->Set(j++, TRI_V8_ASCII_STRING("_path()"));
|
||||
result->Set(j++, TRI_V8_ASCII_STRING("_query()"));
|
||||
|
|
|
@ -2801,7 +2801,7 @@ static void ListDatabasesCoordinator(
|
|||
ClusterInfo* ci = ClusterInfo::instance();
|
||||
|
||||
if (args.Length() == 0) {
|
||||
std::vector<DatabaseID> list = ci->listDatabases(true);
|
||||
std::vector<DatabaseID> list = ci->databases(true);
|
||||
v8::Handle<v8::Array> result = v8::Array::New(isolate);
|
||||
for (size_t i = 0; i < list.size(); ++i) {
|
||||
result->Set((uint32_t)i, TRI_V8_STD_STRING(list[i]));
|
||||
|
@ -2860,13 +2860,13 @@ static void ListDatabasesCoordinator(
|
|||
/// @brief was docuBlock databaseListDatabase
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void JS_ListDatabases(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||
static void JS_Databases(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
uint32_t const argc = args.Length();
|
||||
if (argc > 1) {
|
||||
TRI_V8_THROW_EXCEPTION_USAGE("db._listDatabases()");
|
||||
TRI_V8_THROW_EXCEPTION_USAGE("db._databases()");
|
||||
}
|
||||
|
||||
TRI_vocbase_t* vocbase = GetContextVocBase(isolate);
|
||||
|
@ -3492,8 +3492,8 @@ void TRI_InitV8VocBridge(v8::Isolate* isolate, v8::Handle<v8::Context> context,
|
|||
JS_CreateDatabase);
|
||||
TRI_AddMethodVocbase(isolate, ArangoNS, TRI_V8_ASCII_STRING("_dropDatabase"),
|
||||
JS_DropDatabase);
|
||||
TRI_AddMethodVocbase(isolate, ArangoNS, TRI_V8_ASCII_STRING("_listDatabases"),
|
||||
JS_ListDatabases);
|
||||
TRI_AddMethodVocbase(isolate, ArangoNS, TRI_V8_ASCII_STRING("_databases"),
|
||||
JS_Databases);
|
||||
TRI_AddMethodVocbase(isolate, ArangoNS, TRI_V8_ASCII_STRING("_useDatabase"),
|
||||
JS_UseDatabase);
|
||||
|
||||
|
|
|
@ -57,13 +57,13 @@ function get_api_database (req, res) {
|
|||
var result;
|
||||
if (req.suffix.length === 0) {
|
||||
// list of all databases
|
||||
result = arangodb.db._listDatabases();
|
||||
result = arangodb.db._databases();
|
||||
}
|
||||
else {
|
||||
if (req.suffix[0] === 'user') {
|
||||
// fetch all databases for the current user
|
||||
// note: req.user may be null if authentication is turned off
|
||||
result = arangodb.db._listDatabases(req.user);
|
||||
result = arangodb.db._databases(req.user);
|
||||
}
|
||||
else if (req.suffix[0] === 'current') {
|
||||
if (cluster.isCoordinator()) {
|
||||
|
|
|
@ -14207,7 +14207,7 @@ ArangoDatabase.prototype._createDatabase = function(name,options,users){var data
|
|||
ArangoDatabase.prototype._dropDatabase = function(name){var requestResult=this._connection.DELETE("/_api/database/" + encodeURIComponent(name));if(requestResult !== null && requestResult.error === true){throw new ArangoError(requestResult);}arangosh.checkRequestResult(requestResult);return requestResult.result;}; ////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief list all existing databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ArangoDatabase.prototype._listDatabases = function(){var requestResult=this._connection.GET("/_api/database");if(requestResult !== null && requestResult.error === true){throw new ArangoError(requestResult);}arangosh.checkRequestResult(requestResult);return requestResult.result;}; ////////////////////////////////////////////////////////////////////////////////
|
||||
ArangoDatabase.prototype._databases = function(){var requestResult=this._connection.GET("/_api/database");if(requestResult !== null && requestResult.error === true){throw new ArangoError(requestResult);}arangosh.checkRequestResult(requestResult);return requestResult.result;}; ////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief uses a database
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ArangoDatabase.prototype._useDatabase = function(name){if(internal.printBrowser){throw new ArangoError({error:true,code:internal.errors.ERROR_NOT_IMPLEMENTED.code,errorNum:internal.errors.ERROR_NOT_IMPLEMENTED.code,errorMessage:"_useDatabase() is not supported in the web interface"});}var old=this._connection.getDatabaseName(); // no change
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1006,7 +1006,7 @@ ArangoDatabase.prototype._createDatabase = function(name,options,users){var data
|
|||
ArangoDatabase.prototype._dropDatabase = function(name){var requestResult=this._connection.DELETE("/_api/database/" + encodeURIComponent(name));if(requestResult !== null && requestResult.error === true){throw new ArangoError(requestResult);}arangosh.checkRequestResult(requestResult);return requestResult.result;}; ////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief list all existing databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ArangoDatabase.prototype._listDatabases = function(){var requestResult=this._connection.GET("/_api/database");if(requestResult !== null && requestResult.error === true){throw new ArangoError(requestResult);}arangosh.checkRequestResult(requestResult);return requestResult.result;}; ////////////////////////////////////////////////////////////////////////////////
|
||||
ArangoDatabase.prototype._databases = function(){var requestResult=this._connection.GET("/_api/database");if(requestResult !== null && requestResult.error === true){throw new ArangoError(requestResult);}arangosh.checkRequestResult(requestResult);return requestResult.result;}; ////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief uses a database
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ArangoDatabase.prototype._useDatabase = function(name){if(internal.printBrowser){throw new ArangoError({error:true,code:internal.errors.ERROR_NOT_IMPLEMENTED.code,errorNum:internal.errors.ERROR_NOT_IMPLEMENTED.code,errorMessage:"_useDatabase() is not supported in the web interface"});}var old=this._connection.getDatabaseName(); // no change
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5304,7 +5304,7 @@ ArangoDatabase.prototype._dropDatabase = function (name) {
|
|||
/// @brief list all existing databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ArangoDatabase.prototype._listDatabases = function () {
|
||||
ArangoDatabase.prototype._databases = function () {
|
||||
var requestResult = this._connection.GET("/_api/database");
|
||||
|
||||
if (requestResult !== null && requestResult.error === true) {
|
||||
|
|
|
@ -869,7 +869,7 @@ ArangoDatabase.prototype._dropDatabase = function (name) {
|
|||
/// @brief list all existing databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ArangoDatabase.prototype._listDatabases = function () {
|
||||
ArangoDatabase.prototype._databases = function () {
|
||||
var requestResult = this._connection.GET("/_api/database");
|
||||
|
||||
if (requestResult !== null && requestResult.error === true) {
|
||||
|
|
|
@ -928,7 +928,7 @@ ArangoDatabase.prototype._dropDatabase = function (name) {
|
|||
/// @brief list all existing databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ArangoDatabase.prototype._listDatabases = function () {
|
||||
ArangoDatabase.prototype._databases = function () {
|
||||
var requestResult = this._connection.GET("/_api/database");
|
||||
|
||||
if (requestResult !== null && requestResult.error === true) {
|
||||
|
|
|
@ -171,7 +171,7 @@ function DatabaseSuite () {
|
|||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test _listDatabases function
|
||||
/// @brief test _databases function
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testListDatabases : function () {
|
||||
|
@ -179,7 +179,7 @@ function DatabaseSuite () {
|
|||
|
||||
assertEqual("_system", internal.db._name());
|
||||
|
||||
actual = internal.db._listDatabases();
|
||||
actual = internal.db._databases();
|
||||
assertTrue(Array.isArray(actual));
|
||||
n = actual.length;
|
||||
assertTrue(n > 0);
|
||||
|
@ -200,7 +200,7 @@ function DatabaseSuite () {
|
|||
|
||||
internal.db._createDatabase("UnitTestsDatabase0");
|
||||
|
||||
actual = internal.db._listDatabases();
|
||||
actual = internal.db._databases();
|
||||
assertTrue(Array.isArray(actual));
|
||||
assertEqual(n + 1, actual.length);
|
||||
assertTrue( ( function () {
|
||||
|
@ -550,7 +550,7 @@ function DatabaseSuite () {
|
|||
}
|
||||
|
||||
var isContained = function (name) {
|
||||
var l = internal.db._listDatabases();
|
||||
var l = internal.db._databases();
|
||||
for (var i = 0; i < l.length; ++i) {
|
||||
if (l[i] === name) {
|
||||
return true;
|
||||
|
|
|
@ -490,7 +490,7 @@ function CheckCollection (collection, issues, details) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function main (argv) {
|
||||
var databases = internal.db._listDatabases();
|
||||
var databases = internal.db._databases();
|
||||
var i;
|
||||
|
||||
var collectionSorter = function (l, r) {
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
var dbName = db._name();
|
||||
|
||||
db._useDatabase("_system");
|
||||
var databases = db._listDatabases();
|
||||
var databases = db._databases();
|
||||
|
||||
for (var i = 0; i < databases.length; ++i) {
|
||||
var name = databases[i];
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
try {
|
||||
db._useDatabase('_system');
|
||||
const databases = db._listDatabases();
|
||||
const databases = db._databases();
|
||||
|
||||
// loop over all databases
|
||||
for (const database of databases) {
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
var dbName = db._name();
|
||||
|
||||
db._useDatabase("_system");
|
||||
var databases = db._listDatabases();
|
||||
var databases = db._databases();
|
||||
|
||||
for (var i = 0; i < databases.length; ++i) {
|
||||
var name = databases[i];
|
||||
|
|
|
@ -233,7 +233,7 @@ function getLocalDatabases () {
|
|||
var result = { };
|
||||
var db = require("internal").db;
|
||||
|
||||
db._listDatabases().forEach(function (database) {
|
||||
db._databases().forEach(function (database) {
|
||||
result[database] = { name: database };
|
||||
});
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ function setupReplication () {
|
|||
|
||||
var db = require("internal").db;
|
||||
var rep = require("@arangodb/replication");
|
||||
var dbs = db._listDatabases();
|
||||
var dbs = db._databases();
|
||||
var i;
|
||||
var ok = true;
|
||||
for (i = 0; i < dbs.length; i++) {
|
||||
|
@ -1077,7 +1077,7 @@ function secondaryToPrimary () {
|
|||
console.info("Switching role from secondary to primary...");
|
||||
var db = require("internal").db;
|
||||
var rep = require("@arangodb/replication");
|
||||
var dbs = db._listDatabases();
|
||||
var dbs = db._databases();
|
||||
var i;
|
||||
try {
|
||||
for (i = 0; i < dbs.length; i++) {
|
||||
|
|
|
@ -110,7 +110,7 @@ exports.manage = function() {
|
|||
var expires = global.KEY_GET('queue-control', 'databases-expire') || 0;
|
||||
|
||||
if (expires < now || databases.length === 0) {
|
||||
databases = db._listDatabases();
|
||||
databases = db._databases();
|
||||
global.KEY_SET('queue-control', 'databases', databases);
|
||||
// make list of databases expire in 30 seconds from now
|
||||
global.KEY_SET('queue-control', 'databases-expire', Date.now() + 30 * 1000);
|
||||
|
@ -163,7 +163,7 @@ exports.run = function() {
|
|||
global.KEYSPACE_CREATE('queue-control', 1, true);
|
||||
|
||||
var initialDatabase = db._name();
|
||||
db._listDatabases().forEach(function(name) {
|
||||
db._databases().forEach(function(name) {
|
||||
try {
|
||||
db._useDatabase(name);
|
||||
db._jobs.updateByExample({
|
||||
|
|
|
@ -88,10 +88,10 @@ function recoverySuite () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testCreateDatabaseFail : function () {
|
||||
assertEqual(-1, db._listDatabases().indexOf("UnitTestsRecovery1"));
|
||||
assertEqual(-1, db._listDatabases().indexOf("UnitTestsRecovery2"));
|
||||
assertNotEqual(-1, db._listDatabases().indexOf("UnitTestsRecovery3"));
|
||||
assertNotEqual(-1, db._listDatabases().indexOf("UnitTestsRecovery4"));
|
||||
assertEqual(-1, db._databases().indexOf("UnitTestsRecovery1"));
|
||||
assertEqual(-1, db._databases().indexOf("UnitTestsRecovery2"));
|
||||
assertNotEqual(-1, db._databases().indexOf("UnitTestsRecovery3"));
|
||||
assertNotEqual(-1, db._databases().indexOf("UnitTestsRecovery4"));
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -108,7 +108,7 @@ function recoverySuite () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testLeftoverDatabaseDirectory : function () {
|
||||
assertEqual([ "_system" ], db._listDatabases());
|
||||
assertEqual([ "_system" ], db._databases());
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ function DatabaseSuite () {
|
|||
// drop the database
|
||||
internal.db._dropDatabase("UnitTestsDatabase0");
|
||||
// should be dropped
|
||||
internal.db._listDatabases().forEach(function (d) {
|
||||
internal.db._databases().forEach(function (d) {
|
||||
if (d === "UnitTestsDatabase0") {
|
||||
fail();
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ function DatabaseSuite () {
|
|||
// drop the database
|
||||
internal.db._dropDatabase("UnitTestsDatabase0");
|
||||
// should be dropped
|
||||
internal.db._listDatabases().forEach(function (d) {
|
||||
internal.db._databases().forEach(function (d) {
|
||||
if (d === "UnitTestsDatabase0") {
|
||||
fail();
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ function databaseTestSuite () {
|
|||
testDropDatabase: function () {
|
||||
try {
|
||||
db._dropDatabase("testDB");
|
||||
assertEqual(-1, db._listDatabases().indexOf("testDb"));
|
||||
assertEqual(-1, db._databases().indexOf("testDb"));
|
||||
}
|
||||
catch (e) {
|
||||
fail();
|
||||
|
|
Loading…
Reference in New Issue