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

How to use collection.Watch without the slice/array error?

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 1.0.0-rc2
    • Core API
    • None

    Description

      When using the following code always getting the same error for the 'pipeline' variable that is passed in:
       
      can only transform slices and arrays into aggregation pipelines, but got
       
      Example code:
       
      client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://mongo1:27017,mongo2:27018,mongo3:27019/?replicaSet=my-mongo-set"))

          

      ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)     err = client.Connect(ctx) 
      db := DocumentationDatabase(client) 
      documentation_examples.InsertExamples(t, db) 
       
      // we are going to monitor the inventory collection     
      // for changes     
      coll := db.Collection("inventory") 
       
      var pipeline interface{} // set up pipeline - 
      // in new version has to be a some bsontype.Array but does not work??
      cur, err := coll.Watch(ctx, pipeline, options.ChangeStream()) 
      // above always returns with an error?

       

      Attachments

        Activity

          People

            kris.brandow@mongodb.com Kristofer Brandow (Inactive)
            mkoning Melle
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: