Skip to content

fix: UpdateOneDoc should update documents instead of deleting them - #4

Merged
kael-reviewer[bot] merged 1 commit into
kael-agentsfrom
fix/task-3-update-one-doc-deletes-instead-of-updating
Apr 14, 2026
Merged

fix: UpdateOneDoc should update documents instead of deleting them#4
kael-reviewer[bot] merged 1 commit into
kael-agentsfrom
fix/task-3-update-one-doc-deletes-instead-of-updating

Conversation

@kael-developer

Copy link
Copy Markdown

Summary

Fixes #3UpdateOneDoc in sharedlib/docliteexport.go was silently deleting documents instead of updating them.

Root Cause

The function called collection.DeleteOne(id) and completely ignored the doc parameter:

func UpdateOneDoc(id int64, doc string, name string) {
    collection := getColFromName(name)
    collection.DeleteOne(id)
}

Fix

Updated the function to follow the same pattern as Insert:

  1. Unmarshal the doc JSON string into map[string]interface{}
  2. Return early if unmarshaling fails
  3. Call collection.UpdateOneDoc(id, document) instead of collection.DeleteOne(id)
func UpdateOneDoc(id int64, doc string, name string) {
    collection := getColFromName(name)
    document := make(map[string]interface{})
    err := json.Unmarshal([]byte(doc), &document)
    if err != nil {
        return
    }
    collection.UpdateOneDoc(id, document)
}

Acceptance Criteria Met

  • UpdateOneDoc unmarshals the doc string parameter into map[string]interface{}
  • UpdateOneDoc calls collection.UpdateOneDoc(id, document) instead of collection.DeleteOne(id)
  • ✅ If JSON unmarshaling fails, the function returns early (same pattern as Insert)
  • ✅ No changes to the C header — the signature is already correct
  • ✅ The fix follows the same code style as the existing Insert function

Files Changed

  • sharedlib/docliteexport.go — Fixed UpdateOneDoc function body

@kael-reviewer
kael-reviewer Bot merged commit 9622ef8 into kael-agents Apr 14, 2026
@kael-reviewer
kael-reviewer Bot deleted the fix/task-3-update-one-doc-deletes-instead-of-updating branch April 14, 2026 23:59
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.

0 participants