Skip to content

Chat support feature - #103

Draft
GunaKKIBM wants to merge 2 commits into
IBM:mainfrom
GunaKKIBM:Chat-support-feature
Draft

Chat support feature#103
GunaKKIBM wants to merge 2 commits into
IBM:mainfrom
GunaKKIBM:Chat-support-feature

Conversation

@GunaKKIBM

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Guna K Kambalimath <Guna.Kambalimath@ibm.com>
Signed-off-by: Guna K Kambalimath <Guna.Kambalimath@ibm.com>
Comment on lines +36 to +42
if err != nil {
// If no documents found, this is the first conversation
if err.Error() == "mongo: no documents in result" {
return 1, nil
}
return 0, fmt.Errorf("error finding max conversation_id: %w", err)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err != nil {
// If no documents found, this is the first conversation
if err.Error() == "mongo: no documents in result" {
return 1, nil
}
return 0, fmt.Errorf("error finding max conversation_id: %w", err)
}
if errors.Is(err, mongo.ErrNoDocuments){
// If no documents found, this is the first conversation
return 1, nil
} else if err != nil {
return 0, fmt.Errorf("error finding max conversation_id: %w", err)
}


// InsertChatMessage - insert chat message into the DB
func (db *MongoDB) InsertChatMessage(message *models.ChatMessage) error {
collection := db.Database.Collection("chat_messages")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create a const for this collection name and use that instead of hardcoding this string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants