1
0
Fork 0

fixed caching of collections in arangosh for dropped collections

This commit is contained in:
Jan Steemann 2013-11-12 15:09:55 +01:00
parent 7b3c3ba3b7
commit 0783bb4473
4 changed files with 35 additions and 9 deletions

View File

@ -122,8 +122,9 @@ window.arangoHelper = {
return val.substr(0, 1) === '_';
},
collectionApiType: function (identifier) {
if (this.CollectionTypes[identifier] === undefined) {
collectionApiType: function (identifier, refresh) {
// set "refresh" to disable caching collection type
if (refresh || this.CollectionTypes[identifier] === undefined) {
this.CollectionTypes[identifier] = window.arangoDocumentStore
.getCollectionInfo(identifier).type;
}

View File

@ -407,12 +407,24 @@ ArangoDatabase.prototype._truncate = function (id) {
////////////////////////////////////////////////////////////////////////////////
ArangoDatabase.prototype._drop = function (id) {
var collection = this._collection(id);
var name;
if (collection instanceof this._collectionConstructor) {
return collection.drop();
for (name in this) {
if (this.hasOwnProperty(name)) {
var collection = this[name];
if (collection instanceof this._collectionConstructor) {
if (collection._id === id || collection._name === id) {
return collection.drop();
}
}
}
}
var c = this._collection(id);
if (c) {
return c.drop();
}
return undefined;
};

View File

@ -331,7 +331,8 @@ var documentsView = Backbone.View.extend({
addDocument: function () {
var collid = window.location.hash.split("/")[1];
var doctype = arangoHelper.collectionApiType(collid);
// second parameter is "true" to disable caching of collection type
var doctype = arangoHelper.collectionApiType(collid, true);
if (doctype === 'edge') {
$('#edgeCreateModal').modal('show');

View File

@ -406,12 +406,24 @@ ArangoDatabase.prototype._truncate = function (id) {
////////////////////////////////////////////////////////////////////////////////
ArangoDatabase.prototype._drop = function (id) {
var collection = this._collection(id);
var name;
if (collection instanceof this._collectionConstructor) {
return collection.drop();
for (name in this) {
if (this.hasOwnProperty(name)) {
var collection = this[name];
if (collection instanceof this._collectionConstructor) {
if (collection._id === id || collection._name === id) {
return collection.drop();
}
}
}
}
var c = this._collection(id);
if (c) {
return c.drop();
}
return undefined;
};