refactor(note): lazy-load relations

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-11-30 16:46:07 +01:00
parent d761ff7f4f
commit 235e4f647c
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
23 changed files with 343 additions and 284 deletions

View file

@ -76,8 +76,8 @@ createConnection({
const edit = Edit.create(author, 1, 42) as Edit;
revision.edits = [edit];
notes[i].revisions = Promise.all([revision]);
notes[i].userPermissions = [];
notes[i].groupPermissions = [];
notes[i].userPermissions = Promise.resolve([]);
notes[i].groupPermissions = Promise.resolve([]);
user.ownedNotes = [notes[i]];
await connection.manager.save([
notes[i],
@ -99,7 +99,7 @@ createConnection({
throw new Error('Could not find freshly seeded notes. Aborting.');
}
for (const note of foundNotes) {
if (!note.aliases[0]) {
if (!(await note.aliases)[0]) {
throw new Error(
'Could not find alias of freshly seeded notes. Aborting.',
);
@ -111,7 +111,7 @@ createConnection({
);
}
for (const note of foundNotes) {
console.log(`Created Note '${note.aliases[0].name ?? ''}'`);
console.log(`Created Note '${(await note.aliases)[0].name ?? ''}'`);
}
for (const user of foundUsers) {
for (const note of foundNotes) {
@ -119,7 +119,7 @@ createConnection({
await connection.manager.save(historyEntry);
console.log(
`Created HistoryEntry for user '${user.username}' and note '${
note.aliases[0].name ?? ''
(await note.aliases)[0].name ?? ''
}'`,
);
}