chore: update sqlite functions

This commit is contained in:
Steven
2023-12-17 14:16:34 +08:00
parent a9071d629a
commit 41cb597f03
8 changed files with 37 additions and 98 deletions

View File

@ -2,6 +2,7 @@ package sqlite
import (
"context"
"database/sql"
"fmt"
"strings"
@ -181,3 +182,13 @@ func (d *DB) DeleteCollection(ctx context.Context, delete *store.DeleteCollectio
return nil
}
func vacuumCollection(ctx context.Context, tx *sql.Tx) error {
stmt := `DELETE FROM collection WHERE creator_id NOT IN (SELECT id FROM user)`
_, err := tx.ExecContext(ctx, stmt)
if err != nil {
return err
}
return nil
}