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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: CRUD
    • None
    • Environment:
      ubuntu 18.04 (server&desktop)
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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
      }
      

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

              Created:
              Updated:
              Resolved: