Removed legacy navigationtree

This commit is contained in:
Jori Lallo
2017-10-15 18:35:28 -07:00
parent 53d9e221a5
commit 75bf265bd5
4 changed files with 17 additions and 28 deletions

View File

@ -29,7 +29,6 @@ const Collection = sequelize.define(
creatorId: DataTypes.UUID,
/* type: atlas */
navigationTree: DataTypes.JSONB, // legacy
documentStructure: DataTypes.JSONB,
},
{
@ -98,28 +97,6 @@ Collection.prototype.getUrl = function() {
return `/collections/${this.id}`;
};
Collection.prototype.getDocumentsStructure = async function() {
// Lazy fill this.documentStructure - TMP for internal release
if (!this.documentStructure) {
this.documentStructure = this.navigationTree.children;
// Remove parent references from all root documents
await this.navigationTree.children.forEach(async ({ id }) => {
const document = await Document.findById(id);
document.parentDocumentId = null;
await document.save();
});
// Remove root document
const rootDocument = await Document.findById(this.navigationTree.id);
await rootDocument.destroy();
await this.save();
}
return this.documentStructure;
};
Collection.prototype.addDocumentToStructure = async function(
document,
index,