1
0
Fork 0

make the ArangoShell refill its collection cache (#3441)

This commit is contained in:
Jan 2017-11-02 15:32:48 +01:00 committed by Frank Celler
parent 64e9377c05
commit abc4c09d1e
3 changed files with 22 additions and 2 deletions

View File

@ -1,6 +1,16 @@
devel
-----
* make the ArangoShell refill its collection cache when a yet-unknown collection
is first accessed. This fixes the following problem:
arangosh1> db._collections(); // shell1 lists all collections
arangosh2> db._create("test"); // shell2 now creates a new collection 'test'
arangosh1> db.test.insert({}); // shell1 is not aware of the collection created
// in shell2, so the insert will fail
* make AQL `DISTINCT` not change the order of the results it is applied on
* enable JEMalloc background thread for purging and returning unused memory
back to the operating system (Linux only)

View File

@ -302,7 +302,7 @@ ArangoDatabase.prototype._collections = function () {
ArangoDatabase.prototype._collection = function (id) {
if (typeof id !== 'number' &&
this[id] && this[id] instanceof this._collectionConstructor) {
this.hasOwnProperty(id) && this[id] && this[id] instanceof this._collectionConstructor) {
return this[id];
}
var url;

View File

@ -90,7 +90,17 @@ exports.ArangoView = require('@arangodb/arango-view').ArangoView;
if (typeof internal.arango !== 'undefined') {
try {
exports.arango = internal.arango;
exports.db = new exports.ArangoDatabase(internal.arango);
let db = new exports.ArangoDatabase(internal.arango);
// proxy the db object, so we can track access to non-existing collections
exports.db = new Proxy(db, {
get(target, name) {
if (!target.hasOwnProperty(name) && target[name] === undefined && typeof name === 'string') {
// unknown collection, try re-populating the cache
db._collections();
}
return target[name];
},
});
internal.db = exports.db; // TODO remove
} catch (err) {
internal.print('cannot connect to server: ' + String(err));