convex-ents 0.9.3 → 0.9.5
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/dist/deletion.js +29 -25
- package/dist/deletion.js.map +1 -1
- package/dist/functions.js +22 -12
- package/dist/functions.js.map +1 -1
- package/dist/index.js +21 -12
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +5 -1
- package/dist/schema.js +13 -2
- package/dist/schema.js.map +1 -1
- package/dist/writer.js +21 -11
- package/dist/writer.js.map +1 -1
- package/package.json +1 -1
package/dist/functions.js
CHANGED
|
@@ -30,8 +30,18 @@ __export(functions_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(functions_exports);
|
|
32
32
|
|
|
33
|
-
// src/
|
|
33
|
+
// src/schema.ts
|
|
34
34
|
var import_server = require("convex/server");
|
|
35
|
+
var import_values = require("convex/values");
|
|
36
|
+
function edgeCompoundIndexName(edgeDefinition) {
|
|
37
|
+
return edgeCompoundIndexNameRaw(edgeDefinition.field, edgeDefinition.ref);
|
|
38
|
+
}
|
|
39
|
+
function edgeCompoundIndexNameRaw(idA, idB) {
|
|
40
|
+
return `${idA}_${idB}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/writer.ts
|
|
44
|
+
var import_server2 = require("convex/server");
|
|
35
45
|
var WriterImplBase = class _WriterImplBase {
|
|
36
46
|
constructor(ctx, entDefinitions, table) {
|
|
37
47
|
this.ctx = ctx;
|
|
@@ -88,7 +98,7 @@ var WriterImplBase = class _WriterImplBase {
|
|
|
88
98
|
}
|
|
89
99
|
await this.writeEdges(id, edges, isDeletingSoftly);
|
|
90
100
|
if (deletionConfig !== void 0 && deletionConfig.type === "scheduled") {
|
|
91
|
-
const fnRef = this.ctx.scheduledDelete ?? (0,
|
|
101
|
+
const fnRef = this.ctx.scheduledDelete ?? (0, import_server2.makeFunctionReference)(
|
|
92
102
|
"functions:scheduledDelete"
|
|
93
103
|
);
|
|
94
104
|
await this.ctx.scheduler.runAfter(deletionConfig.delayMs ?? 0, fnRef, {
|
|
@@ -151,9 +161,9 @@ var WriterImplBase = class _WriterImplBase {
|
|
|
151
161
|
}
|
|
152
162
|
if (idOrIds.add !== void 0) {
|
|
153
163
|
await Promise.all(
|
|
154
|
-
idOrIds.add.map(async (id) => {
|
|
164
|
+
[...new Set(idOrIds.add)].map(async (id) => {
|
|
155
165
|
const existing = await this.ctx.db.query(edgeDefinition.table).withIndex(
|
|
156
|
-
edgeDefinition
|
|
166
|
+
edgeCompoundIndexName(edgeDefinition),
|
|
157
167
|
(q) => q.eq(edgeDefinition.field, docId).eq(
|
|
158
168
|
edgeDefinition.ref,
|
|
159
169
|
id
|
|
@@ -804,7 +814,7 @@ var PromiseEdgeOrNullImpl = class _PromiseEdgeOrNullImpl extends PromiseEntsOrNu
|
|
|
804
814
|
return null;
|
|
805
815
|
}
|
|
806
816
|
const edgeDoc = this.ctx.db.query(this.edgeDefinition.table).withIndex(
|
|
807
|
-
|
|
817
|
+
edgeCompoundIndexName(this.edgeDefinition),
|
|
808
818
|
(q) => q.eq(this.edgeDefinition.field, sourceId).eq(
|
|
809
819
|
this.edgeDefinition.ref,
|
|
810
820
|
targetId
|
|
@@ -1268,19 +1278,19 @@ var PromiseEntWriterImpl = class extends PromiseEntOrNullImpl {
|
|
|
1268
1278
|
const { add, remove } = value[key];
|
|
1269
1279
|
const removeEdges = (await Promise.all(
|
|
1270
1280
|
(remove ?? []).map(
|
|
1271
|
-
async (
|
|
1272
|
-
edgeDefinition
|
|
1281
|
+
async (otherId) => (await this.ctx.db.query(edgeDefinition.table).withIndex(
|
|
1282
|
+
edgeCompoundIndexName(edgeDefinition),
|
|
1273
1283
|
(q) => q.eq(edgeDefinition.field, id).eq(
|
|
1274
1284
|
edgeDefinition.ref,
|
|
1275
|
-
|
|
1285
|
+
otherId
|
|
1276
1286
|
)
|
|
1277
1287
|
).collect()).concat(
|
|
1278
1288
|
edgeDefinition.symmetric ? await this.ctx.db.query(edgeDefinition.table).withIndex(
|
|
1279
|
-
edgeDefinition
|
|
1280
|
-
(q) => q.eq(
|
|
1289
|
+
edgeCompoundIndexName(edgeDefinition),
|
|
1290
|
+
(q) => q.eq(
|
|
1281
1291
|
edgeDefinition.field,
|
|
1282
|
-
|
|
1283
|
-
)
|
|
1292
|
+
otherId
|
|
1293
|
+
).eq(edgeDefinition.ref, id)
|
|
1284
1294
|
).collect() : []
|
|
1285
1295
|
)
|
|
1286
1296
|
)
|