document-drive 1.0.0-alpha.7 → 1.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/storage/prisma.ts
CHANGED
|
@@ -58,16 +58,21 @@ export class PrismaStorage implements IDriveStorage {
|
|
|
58
58
|
drive: string,
|
|
59
59
|
id: string,
|
|
60
60
|
operations: Operation[],
|
|
61
|
-
header: DocumentHeader
|
|
61
|
+
header: DocumentHeader,
|
|
62
|
+
updatedOperations: Operation[] = []
|
|
62
63
|
): Promise<void> {
|
|
63
64
|
const document = await this.getDocument(drive, id);
|
|
64
65
|
if (!document) {
|
|
65
66
|
throw new Error(`Document with id ${id} not found`);
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
const mergedOperations = [...operations, ...updatedOperations].sort(
|
|
70
|
+
(a, b) => a.index - b.index
|
|
71
|
+
);
|
|
72
|
+
|
|
68
73
|
try {
|
|
69
74
|
await Promise.all(
|
|
70
|
-
|
|
75
|
+
mergedOperations.map(async op => {
|
|
71
76
|
return this.db.operation.createMany({
|
|
72
77
|
data: {
|
|
73
78
|
driveId: drive,
|
|
@@ -80,7 +85,7 @@ export class PrismaStorage implements IDriveStorage {
|
|
|
80
85
|
scope: op.scope,
|
|
81
86
|
branch: 'main',
|
|
82
87
|
skip: op.skip
|
|
83
|
-
}
|
|
88
|
+
}
|
|
84
89
|
});
|
|
85
90
|
})
|
|
86
91
|
);
|
|
@@ -207,7 +212,6 @@ export class PrismaStorage implements IDriveStorage {
|
|
|
207
212
|
}
|
|
208
213
|
}
|
|
209
214
|
});
|
|
210
|
-
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
async getDrives() {
|
|
@@ -225,9 +229,11 @@ export class PrismaStorage implements IDriveStorage {
|
|
|
225
229
|
|
|
226
230
|
async deleteDrive(id: string) {
|
|
227
231
|
const docs = await this.getDocuments(id);
|
|
228
|
-
await Promise.all(
|
|
229
|
-
|
|
230
|
-
|
|
232
|
+
await Promise.all(
|
|
233
|
+
docs.map(async doc => {
|
|
234
|
+
return this.deleteDocument(id, doc);
|
|
235
|
+
})
|
|
236
|
+
);
|
|
231
237
|
await this.deleteDocument('drives', id);
|
|
232
238
|
}
|
|
233
239
|
}
|