storm icon indicating copy to clipboard operation
storm copied to clipboard

Issue with string composite id

Open jypelle opened this issue 5 years ago • 0 comments

type FavoritePlaylistId struct {
	UserId     string
	PlaylistId string
}

type FavoritePlaylistEntity struct {
	Id         FavoritePlaylistId           `storm:"id"`
	UpdateTs   int64                        `storm:"index"`
	UserId     string                       `storm:"index"`
	PlaylistId string                       `storm:"index"`
}

Steps to reproduce:

  • Open Storm Db
  • Save one FavoritePlaylistEntity
  • Retrieve FavoritePlaylistEntity From Id ->Succed
  • Retrieve FavoritePlaylistEntity From UserId (index) ->Succed
  • Retrieve FavoritePlaylistEntity From PlaylistId (index) ->Succed
  • Retrieve FavoritePlaylistEntity From UserId & PlaylistId ->Succeed
  • Close Storm Db
  • Open Storm Db
  • Retrieve FavoritePlaylistEntity From Id ->Not found!
  • Retrieve FavoritePlaylistEntity From UserId (index) ->Not found!
  • Retrieve FavoritePlaylistEntity From PlaylistId (index) ->Not found!
  • Retrieve FavoritePlaylistEntity From UserId & PlaylistId ->Not found!
  • Retrieve All FavoritePlaylistEntity ->Succeed

I think there is a pb when you close and reopen the database. Don't know if it's a bbolt issue or a storm issue.

Found a workaround replacing:

Id         FavoritePlaylistId           `storm:"id"`

With

Id         string           `storm:"id"`

And calculate Id with concatenation (Id= UserId+':'+PlaylistId)

jypelle avatar Oct 24 '19 14:10 jypelle