update method CreateQuestion, now id question return
This commit is contained in:
parent
52320d3bac
commit
b0f7572884
@ -32,7 +32,7 @@ func NewQuestionRepository(deps Deps) *QuestionRepository {
|
||||
}
|
||||
|
||||
// test +
|
||||
func (r *QuestionRepository) CreateQuestion(ctx context.Context, record *model.Question) error {
|
||||
func (r *QuestionRepository) CreateQuestion(ctx context.Context, record *model.Question) (uint64, error) {
|
||||
params := sqlcgen.InsertQuestionParams{
|
||||
QuizID: int64(record.QuizId),
|
||||
Title: record.Title,
|
||||
@ -47,14 +47,14 @@ func (r *QuestionRepository) CreateQuestion(ctx context.Context, record *model.Q
|
||||
|
||||
data, err := r.queries.InsertQuestion(ctx, params)
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
record.Id = uint64(data.ID)
|
||||
record.CreatedAt = data.CreatedAt.Time
|
||||
record.UpdatedAt = data.UpdatedAt.Time
|
||||
|
||||
return nil
|
||||
return record.Id, nil
|
||||
}
|
||||
|
||||
// test +
|
||||
|
Loading…
Reference in New Issue
Block a user