fix: Unique ID doesn't fail at first try
Fixes #3 Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
711327390f
commit
e22105049a
1 changed files with 3 additions and 4 deletions
|
@ -29,11 +29,10 @@ func (n *Note) BeforeCreate(tx *gorm.DB) (err error) {
|
|||
|
||||
id := internal.GenerateChars(idLength)
|
||||
|
||||
var note *Note
|
||||
tx.Where("id = ?", id).Scan(¬e)
|
||||
var note Note
|
||||
tx.Where("id = ?", id).Find(¬e)
|
||||
|
||||
// TODO: time=2025-08-21T09:20:31.342+02:00 level=ERROR msg="could not create note" error="UNIQUE constraint failed: notes.id"
|
||||
if note == nil {
|
||||
if note.ID == "" {
|
||||
n.ID = id
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue