in my gorm postgress db, my database display error as it is not bigint type for the user id

in my gorm postgress db, my database display error as it is not bigint type for the user id


0

my gqlgen go app with postgres

based on the schema when i try to implement the function it display error as it is not bigint type for the user id, but the user id in the user struct generated by gqlgen are 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
}

//my 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

}

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 4 more related questions


Show fewer related questions

0



Leave a Reply

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