Gorm postgress DB database display error: bigint type for the user id

Gorm postgress DB database display error: bigint type for the user id


0

Based on the schema below, when I try to implement the function, it displays an error as it’s not a bigint type for the user id, but the user id in the user struct generated by gqlgen is a string.

My schema:

type Query {
  getUser(id: ID!): Users!
  listUsers: [Users!]!
}

type Mutation {
  createUser(input: CreateUserInput!): Users!
  updateUser(input: UpdateUserInput!): Users!
  deleteUser(id: ID!): Boolean!
   
}

type Users {
  id: ID!
  name: String!
  email: String!
}

input CreateUserInput {
  name: String!
  email: String!
}

input UpdateUserInput {
  id: ID!
  name: String
  email: String
}

Resolver function:

// CreateUser is the resolver for the createUser field.
func (r *mutationResolver) CreateUser(ctx context.Context, input model.CreateUserInput) (*model.Users, error) {
    // Create a new user object
    user := &model.Users{
                ID:uuid.new().string()
        Name:  input.Name,
        Email: input.Email,
    }
    fmt.Println("frfrf" + user.ID)
    // TODO: Implement the code to save the user to the database using go-pg
    // Example code:
    _, err := r.DB.Model(user).Insert()

    // Check for any errors
    if err != nil {
        return nil, err
    }

    // Return the created user
    return user, nil
}

Any ideas on how to resolve this issue?

New contributor

melkamu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


Load 3 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *