1
0
Fork 0
forked from jriou/coller

fix: convert id to int64

Snowflake identifiers are integers, not strings.

BREAKING CHANGE: notes that are not using snowflake identifiers will not be
compatible anymore.

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2025-09-27 10:05:58 +02:00
commit 1fcde736a8
Signed by: jriou
GPG key ID: 9A099EDA51316854
6 changed files with 9 additions and 9 deletions

View file

@ -112,7 +112,7 @@ func (d *Database) Get(id string) (*Note, error) {
d.logger.Warn("could not find note", slog.Any("error", trx.Error))
return nil, trx.Error
}
if note.ID != "" {
if note.ID != 0 {
if note.DeleteAfterRead {
if err := d.Delete(note.ID); err != nil {
return nil, err
@ -142,7 +142,7 @@ func (d *Database) Create(content []byte, password string, encryptionKey string,
}
note = &Note{
ID: d.node.Generate().String(),
ID: d.node.Generate().Int64(),
Content: content,
ExpiresAt: time.Now().Add(time.Duration(expiration) * time.Second),
Encrypted: encrypted,
@ -179,7 +179,7 @@ func (d *Database) Create(content []byte, password string, encryptionKey string,
return note, nil
}
func (d *Database) Delete(id string) error {
func (d *Database) Delete(id int64) error {
trx := d.db.Where("id = ?", id).Delete(&Note{})
defer trx.Commit()
if trx.Error != nil {