Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-730

Find does not return an error if there are no objects.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • CRUD
    • None
    • ubuntu 18.04 (server&desktop)

    Description

      There is a call to find:

      cursor, err := s.db.Collection(collectionNotification).Find(ctx, bson.M\{"terminal_id": bson.M{"$in": terminalList}, "status": status})
      if err != nil {
       return err
      }
      

      In the case when the documents are not found, the error is not returned.
      You have to do an additional check to handle the error.

      if !cursor.Next(ctx) {
       return nil, mongo.ErrNoDocuments
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            pocoz John Daniels
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: