XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: 0.2.0
    • Component/s: CRUD
    • Environment:
      Ubuntu 18.04, Mongo version 4.0, GO version 1.11
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When searching for objects using $in, the cursor always drops the first found object. All subsequent displays are normal.

      ids := []string{"1","2","3"}
      filter := bson.M{"terminal_id": bson.M{"$in": ids}}
      cursor, err := s.db.Collection(collectionTerminal).Find(ctx, filter)
      if err != nil {
         return nil, err
      }
      defer cursor.Close(ctx)
      
      var terminalList []*terminal.Terminal
      for cursor.Next(ctx) {
         var term *terminal.Terminal
         err := cursor.Decode(&term)
         if err != nil {
            fmt.Println(err)
            return nil, err
         }
         terminalList = append(terminalList, term)
      }
      // in terminalList: [{"id":"2"}, {"id":"3"}]
      // must be: [{"id":"1"}, {"id":"2"}, {"id":"3"}]
      

       

       

            Assignee:
            Isabella Siu (Inactive)
            Reporter:
            John Daniels
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: