Skip to content

Commit

Permalink
bump record datestamp on delete (resolves #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
nics committed Aug 31, 2023
1 parent 2d9801a commit b198849
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion repositories/repo.go
Expand Up @@ -467,10 +467,27 @@ func (r *Repo) AddRecordMetadata(ctx context.Context, identifier, prefix, conten
}

func (r *Repo) DeleteRecord(ctx context.Context, identifier string) error {
return r.client.Record.Update().
tx, err := r.client.Tx(ctx)
if err != nil {
return err
}
err = tx.Record.Update().
Where(record.IdentifierEQ(identifier)).
SetDeleted(true).
Exec(ctx)
if err != nil {
tx.Rollback()
return err
}
err = tx.Metadata.Update().
Where(metadata.HasRecordWith(record.IdentifierEQ(identifier))).
SetDatestamp(time.Now()).
Exec(ctx)
if err != nil {
tx.Rollback()
return err
}
return tx.Commit()
}

func (r *Repo) encodeCursor(c any) (string, error) {
Expand Down

0 comments on commit b198849

Please sign in to comment.