Pg: Error pg: Model(unsupported *db.Domain)

Created on 30 Sep 2017  路  3Comments  路  Source: go-pg/pg

Hi.

I have a problem. Did go get -u, and now that that worked earlier, produces an error at compilation.

Structure

type Domain struct {
    tableName   struct{}  `sql:"domain,alias:d"`
    Id          int       `sql:",pk" json:"id"`
    Domain      string    `json:"domain"`
    Description string    `json:"description"`
    Aliases     int       `json:"aliases"`
    Mailboxes   int       `json:"mailboxes"`
    Maxquota    int       `json:"maxquota"`
    Created     time.Time `json:"created"`
    Modified    time.Time `json:"modified"`
    Active      bool      `json:"active"`
}

Call

func (d *Domain) GetById() error {
    err := Db.Model(&d).Where("id=?", d.Id).Select()
    return err
}

I can not understand what has changed?

Most helpful comment

Change Db.Model(&d) to Db.Model(d) since d is already a pointer.

All 3 comments

Change Db.Model(&d) to Db.Model(d) since d is already a pointer.

If you do as you say, I get an error. pg: Model (non-pointer [] db.Domain).

Yeah, but that is completely different code. Overall you should pass a pointer to the object, not a pointer to a pointer as in your question.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kieusonlam picture kieusonlam  路  6Comments

noggan picture noggan  路  5Comments

Labutin picture Labutin  路  3Comments

willsr picture willsr  路  5Comments

owentran picture owentran  路  6Comments