Currently, I am utilizing the mongo-go-driver () and attempting to achieve a similar action as below:
db.getCollection('mycollection').aggregate([
{ $lookup: {
from: "anothercollection",
localField: "_id",
foreignField: "foreignID",
as: "matched_docs"
}},
{ $match: { "matched_docs": { $eq: [] } } },
{ $project: { "matched_docs": 0 } },
{ $match: {"dateTimeGMT":{$lt: (new Date(Date.now()-1000*60*60*24)).toISOString()}} }
])
I'm encountering difficulty in integrating the JavaScript commands using this approach.
pipeline := bson.NewArray(
bson.VC.DocumentFromElements(
bson.EC.SubDocumentFromElements(
//blah, blah, blah...
cursor, err := collection.Aggregate(ctx, pipeline)
(In general, I'm not fond of this technique. I desire the ability to develop queries in Robo 3T and easily transfer them into my code similar to how I perform with MySQL Workbench and PHP)
This method results in an empty *bson.Array within the pipeline
pipelineJSON := `[
{ $lookup: {
from: "anothercollection",
localField: "_id",
foreignField: "interactionID",
as: "matched_docs"
}},
{ $match: { "matched_docs": { $eq: [] } } },
{ $project: { "matched_docs": 0 } },
{ $match: {"dateTimeGMT":{$lt: (new Date(Date.now()-1000*60*60*24)).toISOString()}} }
]`
pipeline, err = bson.ParseExtJSONArray(pipelineJSON)
I would greatly appreciate it if there was a way to transmit a MongoDB command as a string (like inputting it into Robo 3T) and receive a *mongo.Cursor in return. Is there a superior driver available (that is still actively supported by developers) that I should consider using instead? Or perhaps, do I need to develop my own?
Thank you!