Add hookDatabaseInit() call to perform ops on DB startup

This commit is contained in:
Gregory Schier
2018-12-03 13:43:43 -05:00
parent de03bba8fc
commit 8eb494dfe8
2 changed files with 10 additions and 0 deletions

View File

@@ -127,6 +127,12 @@ export async function init(types: Array<string>, config: Object = {}, forceReset
}
}
});
for (const model of models.all()) {
if (typeof model.hookDatabaseInit === 'function') {
await model.hookDatabaseInit();
}
}
}
// ~~~~~~~~~~~~~~~~ //

View File

@@ -79,6 +79,10 @@ export async function migrate(doc: Object) {
return doc;
}
export async function hookDatabaseInit() {
console.log('Init responses DB');
}
export function hookRemove(doc: Response) {
if (!doc.bodyPath) {
return;