convex-ents 0.9.2 → 0.9.4

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/functions.js CHANGED
@@ -30,8 +30,15 @@ __export(functions_exports, {
30
30
  });
31
31
  module.exports = __toCommonJS(functions_exports);
32
32
 
33
- // src/writer.ts
33
+ // src/schema.ts
34
34
  var import_server = require("convex/server");
35
+ var import_values = require("convex/values");
36
+ function edgeCompoundIndexName(idA, idB) {
37
+ return `${idA}_${idB}`;
38
+ }
39
+
40
+ // src/writer.ts
41
+ var import_server2 = require("convex/server");
35
42
  var WriterImplBase = class _WriterImplBase {
36
43
  constructor(ctx, entDefinitions, table) {
37
44
  this.ctx = ctx;
@@ -88,7 +95,7 @@ var WriterImplBase = class _WriterImplBase {
88
95
  }
89
96
  await this.writeEdges(id, edges, isDeletingSoftly);
90
97
  if (deletionConfig !== void 0 && deletionConfig.type === "scheduled") {
91
- const fnRef = this.ctx.scheduledDelete ?? (0, import_server.makeFunctionReference)(
98
+ const fnRef = this.ctx.scheduledDelete ?? (0, import_server2.makeFunctionReference)(
92
99
  "functions:scheduledDelete"
93
100
  );
94
101
  await this.ctx.scheduler.runAfter(deletionConfig.delayMs ?? 0, fnRef, {
@@ -153,7 +160,10 @@ var WriterImplBase = class _WriterImplBase {
153
160
  await Promise.all(
154
161
  idOrIds.add.map(async (id) => {
155
162
  const existing = await this.ctx.db.query(edgeDefinition.table).withIndex(
156
- edgeDefinition.field,
163
+ edgeCompoundIndexName(
164
+ edgeDefinition.field,
165
+ edgeDefinition.ref
166
+ ),
157
167
  (q) => q.eq(edgeDefinition.field, docId).eq(
158
168
  edgeDefinition.ref,
159
169
  id
@@ -804,7 +814,10 @@ 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
- `${this.edgeDefinition.field}_${this.edgeDefinition.ref}`,
817
+ edgeCompoundIndexName(
818
+ this.edgeDefinition.field,
819
+ this.edgeDefinition.ref
820
+ ),
808
821
  (q) => q.eq(this.edgeDefinition.field, sourceId).eq(
809
822
  this.edgeDefinition.ref,
810
823
  targetId
@@ -999,7 +1012,7 @@ var PromiseEntOrNullImpl = class extends Promise {
999
1012
  return new PromiseEdgeOrNullImpl(
1000
1013
  this.ctx,
1001
1014
  this.entDefinitions,
1002
- this.table,
1015
+ edgeDefinition.to,
1003
1016
  edgeDefinition,
1004
1017
  async () => {
1005
1018
  const { id } = await this.retrieve();