+20
-12
server/repo.go
+20
-12
server/repo.go
···
106
r, err := repo.OpenRepo(context.TODO(), dbs, rootcid)
107
108
entries := []models.Record{}
109
110
for i, op := range writes {
111
if op.Type != OpTypeCreate && op.Rkey == nil {
···
136
Cid: nc.String(),
137
Value: d,
138
})
139
case OpTypeDelete:
140
err := r.DeleteRecord(context.TODO(), op.Collection+"/"+*op.Rkey)
141
if err != nil {
···
156
Cid: nc.String(),
157
Value: d,
158
})
159
}
160
}
161
···
221
}
222
}
223
224
-
var results []ApplyWriteResult
225
-
226
var blobs []lexutil.LexLink
227
for _, entry := range entries {
228
if err := rm.s.db.Clauses(clause.OnConflict{
···
241
for _, c := range cids {
242
blobs = append(blobs, lexutil.LexLink(c))
243
}
244
-
245
-
results = append(results, ApplyWriteResult{
246
-
Uri: "at://" + urepo.Did + "/" + entry.Nsid + "/" + entry.Rkey,
247
-
Cid: entry.Cid,
248
-
Commit: &RepoCommit{
249
-
Cid: newroot.String(),
250
-
Rev: rev,
251
-
},
252
-
ValidationStatus: to.StringPtr("valid"), // TODO: obviously this might not be true atm lol
253
-
})
254
}
255
256
rm.s.evtman.AddEvent(context.TODO(), &events.XRPCStreamEvent{
···
269
270
if err := dbs.UpdateRepo(context.TODO(), newroot, rev); err != nil {
271
return nil, err
272
}
273
274
return results, nil
···
106
r, err := repo.OpenRepo(context.TODO(), dbs, rootcid)
107
108
entries := []models.Record{}
109
+
var results []ApplyWriteResult
110
111
for i, op := range writes {
112
if op.Type != OpTypeCreate && op.Rkey == nil {
···
137
Cid: nc.String(),
138
Value: d,
139
})
140
+
results = append(results, ApplyWriteResult{
141
+
Type: OpTypeCreate.String(),
142
+
Uri: "at://" + urepo.Did + "/" + op.Collection + "/" + *op.Rkey,
143
+
Cid: nc.String(),
144
+
ValidationStatus: to.StringPtr("valid"), // TODO: obviously this might not be true atm lol
145
+
})
146
case OpTypeDelete:
147
err := r.DeleteRecord(context.TODO(), op.Collection+"/"+*op.Rkey)
148
if err != nil {
···
163
Cid: nc.String(),
164
Value: d,
165
})
166
+
results = append(results, ApplyWriteResult{
167
+
Type: OpTypeUpdate.String(),
168
+
Uri: "at://" + urepo.Did + "/" + op.Collection + "/" + *op.Rkey,
169
+
Cid: nc.String(),
170
+
ValidationStatus: to.StringPtr("valid"), // TODO: obviously this might not be true atm lol
171
+
})
172
}
173
}
174
···
234
}
235
}
236
237
var blobs []lexutil.LexLink
238
for _, entry := range entries {
239
if err := rm.s.db.Clauses(clause.OnConflict{
···
252
for _, c := range cids {
253
blobs = append(blobs, lexutil.LexLink(c))
254
}
255
}
256
257
rm.s.evtman.AddEvent(context.TODO(), &events.XRPCStreamEvent{
···
270
271
if err := dbs.UpdateRepo(context.TODO(), newroot, rev); err != nil {
272
return nil, err
273
+
}
274
+
275
+
for i := range results {
276
+
results[i].Commit = &RepoCommit{
277
+
Cid: newroot.String(),
278
+
Rev: rev,
279
+
}
280
}
281
282
return results, nil