Gorm select where isn't working

I need to execute a query with Gorm.
This one: SELECT * FROM sessionusernames WHERE username = 'Erwan';
It gives me this result : 1|2018-11-25 19:16:10.993609942+01:00|2018-11-25 19:16:10.993609942+01:00|2018-11-25 19:16:11.21314659+01:00|Erwan|mszpxWpUx4uQsCTxrvBbmJdvUoh3
That’s exactly what I want !

I did this

type Sessionusername struct {
	Username string `gorm:"not null;unique"`
	Token    string

var session Sessionusername
db.Table("sessionusernames").Where("username = ?", "Erwan").First(&session)
if (Sessionusername{}) == session {

But session is empty
Do you have an idea ?

I should maby use SQL delete instead of Gorm soft delete

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.