We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go-zero自动生成的crud如下:
subscriptionsModel interface { Insert(ctx context.Context, data *Subscriptions) (sql.Result, error) FindOne(ctx context.Context, id int64) (*Subscriptions, error) Update(ctx context.Context, data *Subscriptions) error Delete(ctx context.Context, id int64) error } usersModel interface { Insert(ctx context.Context, data *Users) (sql.Result, error) FindOne(ctx context.Context, id int64) (*Users, error) Update(ctx context.Context, data *Users) error Delete(ctx context.Context, id int64) error }
如果我想使用事务,应该怎么样直接调用生成的crud? 难道我只能重新写一个insert和update方法来操作吗,像这样。有没有更方便的方法?
err = c.Conn.TransactCtx(context.Background(), func(ctx context.Context, session sqlx.Session) error { query, _, err := goqu.Dialect("mysql").Insert(c.SubscriptionsModel.GetTableName()).Rows(subscription).ToSQL() if err != nil { return err } r, err := session.ExecCtx(ctx, query) if err != nil { return err } subscription.Id, _ = r.LastInsertId() query, _, err = goqu.Dialect("mysql").Update(c.UsersModel.GetTableName()). Set(goqu.Record{"last_subscription_id": subscription.Id}). Where(goqu.Ex{"id": user.Id}). ToSQL() if err != nil { return err } _, err = session.ExecCtx(ctx, query) if err != nil { return err } return nil })
The text was updated successfully, but these errors were encountered:
Not supported yet, and no plan to support it.
Sorry, something went wrong.
No branches or pull requests
go-zero自动生成的crud如下:
如果我想使用事务,应该怎么样直接调用生成的crud?
难道我只能重新写一个insert和update方法来操作吗,像这样。有没有更方便的方法?
The text was updated successfully, but these errors were encountered: