convex-ents 0.9.4 → 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.map +1 -1
- package/dist/functions.js +14 -17
- package/dist/functions.js.map +1 -1
- package/dist/index.js +16 -19
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +4 -1
- package/dist/schema.js +6 -3
- package/dist/schema.js.map +1 -1
- package/dist/writer.js +14 -17
- package/dist/writer.js.map +1 -1
- package/package.json +1 -1
package/dist/functions.js
CHANGED
|
@@ -33,7 +33,10 @@ module.exports = __toCommonJS(functions_exports);
|
|
|
33
33
|
// src/schema.ts
|
|
34
34
|
var import_server = require("convex/server");
|
|
35
35
|
var import_values = require("convex/values");
|
|
36
|
-
function edgeCompoundIndexName(
|
|
36
|
+
function edgeCompoundIndexName(edgeDefinition) {
|
|
37
|
+
return edgeCompoundIndexNameRaw(edgeDefinition.field, edgeDefinition.ref);
|
|
38
|
+
}
|
|
39
|
+
function edgeCompoundIndexNameRaw(idA, idB) {
|
|
37
40
|
return `${idA}_${idB}`;
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -158,12 +161,9 @@ var WriterImplBase = class _WriterImplBase {
|
|
|
158
161
|
}
|
|
159
162
|
if (idOrIds.add !== void 0) {
|
|
160
163
|
await Promise.all(
|
|
161
|
-
idOrIds.add.map(async (id) => {
|
|
164
|
+
[...new Set(idOrIds.add)].map(async (id) => {
|
|
162
165
|
const existing = await this.ctx.db.query(edgeDefinition.table).withIndex(
|
|
163
|
-
edgeCompoundIndexName(
|
|
164
|
-
edgeDefinition.field,
|
|
165
|
-
edgeDefinition.ref
|
|
166
|
-
),
|
|
166
|
+
edgeCompoundIndexName(edgeDefinition),
|
|
167
167
|
(q) => q.eq(edgeDefinition.field, docId).eq(
|
|
168
168
|
edgeDefinition.ref,
|
|
169
169
|
id
|
|
@@ -814,10 +814,7 @@ var PromiseEdgeOrNullImpl = class _PromiseEdgeOrNullImpl extends PromiseEntsOrNu
|
|
|
814
814
|
return null;
|
|
815
815
|
}
|
|
816
816
|
const edgeDoc = this.ctx.db.query(this.edgeDefinition.table).withIndex(
|
|
817
|
-
edgeCompoundIndexName(
|
|
818
|
-
this.edgeDefinition.field,
|
|
819
|
-
this.edgeDefinition.ref
|
|
820
|
-
),
|
|
817
|
+
edgeCompoundIndexName(this.edgeDefinition),
|
|
821
818
|
(q) => q.eq(this.edgeDefinition.field, sourceId).eq(
|
|
822
819
|
this.edgeDefinition.ref,
|
|
823
820
|
targetId
|
|
@@ -1281,19 +1278,19 @@ var PromiseEntWriterImpl = class extends PromiseEntOrNullImpl {
|
|
|
1281
1278
|
const { add, remove } = value[key];
|
|
1282
1279
|
const removeEdges = (await Promise.all(
|
|
1283
1280
|
(remove ?? []).map(
|
|
1284
|
-
async (
|
|
1285
|
-
edgeDefinition
|
|
1281
|
+
async (otherId) => (await this.ctx.db.query(edgeDefinition.table).withIndex(
|
|
1282
|
+
edgeCompoundIndexName(edgeDefinition),
|
|
1286
1283
|
(q) => q.eq(edgeDefinition.field, id).eq(
|
|
1287
1284
|
edgeDefinition.ref,
|
|
1288
|
-
|
|
1285
|
+
otherId
|
|
1289
1286
|
)
|
|
1290
1287
|
).collect()).concat(
|
|
1291
1288
|
edgeDefinition.symmetric ? await this.ctx.db.query(edgeDefinition.table).withIndex(
|
|
1292
|
-
edgeDefinition
|
|
1293
|
-
(q) => q.eq(
|
|
1289
|
+
edgeCompoundIndexName(edgeDefinition),
|
|
1290
|
+
(q) => q.eq(
|
|
1294
1291
|
edgeDefinition.field,
|
|
1295
|
-
|
|
1296
|
-
)
|
|
1292
|
+
otherId
|
|
1293
|
+
).eq(edgeDefinition.ref, id)
|
|
1297
1294
|
).collect() : []
|
|
1298
1295
|
)
|
|
1299
1296
|
)
|