Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How to insert a record with a foreign key using beego orm?

I have two tables: child and dog. The dog table contains a foreign key reference to the child table. I specify the id of a specific child when inserting a dog record. I don't know how to implement it. Does anyone know how to do it? Can you give me a sample program? Thanks

type child struct(
    id int64 `orm:"pk;auto"`
    name string

);


type dog struct(
    id int64 `orm:"pk;auto"`
    dog string
     child *child `orm:"rel(fk);null;on_delete(set_null)"`
);

Comments