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/index.js
CHANGED
|
@@ -134,13 +134,13 @@ function defineEntSchema(schema, options) {
|
|
|
134
134
|
const edgeTable = defineEnt({
|
|
135
135
|
[forwardId]: import_values.v.id(tableName),
|
|
136
136
|
[inverseId]: import_values.v.id(otherTableName)
|
|
137
|
-
}).index(forwardId, [forwardId]).index(inverseId, [inverseId]).index(
|
|
137
|
+
}).index(forwardId, [forwardId]).index(inverseId, [inverseId]).index(edgeCompoundIndexNameRaw(forwardId, inverseId), [
|
|
138
138
|
forwardId,
|
|
139
139
|
inverseId
|
|
140
140
|
]);
|
|
141
141
|
const isSymmetric = inverseEdge === void 0;
|
|
142
142
|
if (!isSymmetric) {
|
|
143
|
-
edgeTable.index(
|
|
143
|
+
edgeTable.index(edgeCompoundIndexNameRaw(inverseId, forwardId), [
|
|
144
144
|
inverseId,
|
|
145
145
|
forwardId
|
|
146
146
|
]);
|
|
@@ -164,7 +164,10 @@ function defineEntSchema(schema, options) {
|
|
|
164
164
|
}
|
|
165
165
|
return (0, import_server.defineSchema)(schema, options);
|
|
166
166
|
}
|
|
167
|
-
function edgeCompoundIndexName(
|
|
167
|
+
function edgeCompoundIndexName(edgeDefinition) {
|
|
168
|
+
return edgeCompoundIndexNameRaw(edgeDefinition.field, edgeDefinition.ref);
|
|
169
|
+
}
|
|
170
|
+
function edgeCompoundIndexNameRaw(idA, idB) {
|
|
168
171
|
return `${idA}_${idB}`;
|
|
169
172
|
}
|
|
170
173
|
function canBeInverseEdge(tableName, edge, isSelfDirected) {
|
|
@@ -522,12 +525,9 @@ var WriterImplBase = class _WriterImplBase {
|
|
|
522
525
|
}
|
|
523
526
|
if (idOrIds.add !== void 0) {
|
|
524
527
|
await Promise.all(
|
|
525
|
-
idOrIds.add.map(async (id) => {
|
|
528
|
+
[...new Set(idOrIds.add)].map(async (id) => {
|
|
526
529
|
const existing = await this.ctx.db.query(edgeDefinition.table).withIndex(
|
|
527
|
-
edgeCompoundIndexName(
|
|
528
|
-
edgeDefinition.field,
|
|
529
|
-
edgeDefinition.ref
|
|
530
|
-
),
|
|
530
|
+
edgeCompoundIndexName(edgeDefinition),
|
|
531
531
|
(q) => q.eq(edgeDefinition.field, docId).eq(
|
|
532
532
|
edgeDefinition.ref,
|
|
533
533
|
id
|
|
@@ -1178,10 +1178,7 @@ var PromiseEdgeOrNullImpl = class _PromiseEdgeOrNullImpl extends PromiseEntsOrNu
|
|
|
1178
1178
|
return null;
|
|
1179
1179
|
}
|
|
1180
1180
|
const edgeDoc = this.ctx.db.query(this.edgeDefinition.table).withIndex(
|
|
1181
|
-
edgeCompoundIndexName(
|
|
1182
|
-
this.edgeDefinition.field,
|
|
1183
|
-
this.edgeDefinition.ref
|
|
1184
|
-
),
|
|
1181
|
+
edgeCompoundIndexName(this.edgeDefinition),
|
|
1185
1182
|
(q) => q.eq(this.edgeDefinition.field, sourceId).eq(
|
|
1186
1183
|
this.edgeDefinition.ref,
|
|
1187
1184
|
targetId
|
|
@@ -1645,19 +1642,19 @@ var PromiseEntWriterImpl = class extends PromiseEntOrNullImpl {
|
|
|
1645
1642
|
const { add, remove } = value[key];
|
|
1646
1643
|
const removeEdges = (await Promise.all(
|
|
1647
1644
|
(remove ?? []).map(
|
|
1648
|
-
async (
|
|
1649
|
-
edgeDefinition
|
|
1645
|
+
async (otherId) => (await this.ctx.db.query(edgeDefinition.table).withIndex(
|
|
1646
|
+
edgeCompoundIndexName(edgeDefinition),
|
|
1650
1647
|
(q) => q.eq(edgeDefinition.field, id).eq(
|
|
1651
1648
|
edgeDefinition.ref,
|
|
1652
|
-
|
|
1649
|
+
otherId
|
|
1653
1650
|
)
|
|
1654
1651
|
).collect()).concat(
|
|
1655
1652
|
edgeDefinition.symmetric ? await this.ctx.db.query(edgeDefinition.table).withIndex(
|
|
1656
|
-
edgeDefinition
|
|
1657
|
-
(q) => q.eq(
|
|
1653
|
+
edgeCompoundIndexName(edgeDefinition),
|
|
1654
|
+
(q) => q.eq(
|
|
1658
1655
|
edgeDefinition.field,
|
|
1659
|
-
|
|
1660
|
-
)
|
|
1656
|
+
otherId
|
|
1657
|
+
).eq(edgeDefinition.ref, id)
|
|
1661
1658
|
).collect() : []
|
|
1662
1659
|
)
|
|
1663
1660
|
)
|