[GODRIVER-1335] Pipe & iter types equivalent in new golang driver Created: 09/Oct/19  Updated: 28/Oct/19  Resolved: 28/Oct/19

Status: Closed
Project: Go Driver
Component/s: API
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: chakrapani velugubantla Assignee: Divjot Arora (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File pipeline.go    

 Description   

Hello ,

I leverage mongoeye(https://github.com/mongoeye) which leverages mgo.v2(https://godoc.org/gopkg.in/mgo.v2) for getting key info & types across collection . I ran into edge-cases around ssl & authmechanism which new driver addresses . however, i am wondering if there is any roadmap to create mgo.Pipe & Mgo.Iter types in newest driver or their functionality or if there is a way to grab key info across collection in newest driver

 

thanks

chakri



 Comments   
Comment by Divjot Arora (Inactive) [ 11/Oct/19 ]

Thanks for the clarification chakri123@gmail.com. The BatchSize and AllowDiskUse options can be leveraged through the options package. I don't know what kind of pipeline you'd need off the top of my head to get the keys in a collection. Looking at your code sample, however, it seems like you have multiple stages, each of which is a bson.M. You can do the same thing in the Go driver as the pipeline parameter will accept a slice of documents. To put it all together, here's a small code sample:

// stages is []bson.M
aggregateOptions := options.Aggregate().SetBatchSize(2).AllowDiskUse(true)
cursor, err := coll.Aggregate(context.Background, stages, aggregateOptions)
if err != nil { log.Fatal(err) }
// iterate cursor to get each document returned by the aggregation

Let us know if you have any other questions about aggregations in the driver.

– Divjot

Comment by chakrapani velugubantla [ 11/Oct/19 ]

Hello ,

pipeline.go im looking for batch & allowdiskuse functions for pipe wondering if these were part of aggregations . 

regarding grab keys. to elaborate on that.. is there a way to get all keys within a collection for example:

 

collection doc sample will be 

 

{"key1": "val1" , "key2" : "val2" , "key3" : [ \{"key3-1" : "val3-1" , "key-3-2" : "val-3-2" }

]}

 

looking for a way to get key1, key2 , key3.key3-1 , key3.key-3-2 

 

thanks

CHakri

 

 

Comment by Divjot Arora (Inactive) [ 10/Oct/19 ]

Also, we weren't sure what you meant by "grab key info across collection". Can you elaborate on this?

Comment by Divjot Arora (Inactive) [ 10/Oct/19 ]

Hi chakri123@gmail.com,

Looking at the mgo source code, it looks like the Pipe type is used for aggregations, which can be done through the Collection.Aggregate and Database.Aggregate functions in the driver. The Iter type maps to the driver's mongo.Cursor type, which is returned from functions like Find and Aggregate. Is there specific functionality from the mgo types that you need that isn't present in the driver?

Generated at Thu Feb 08 08:36:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.