MongoDB SSIS with $unwind -
i started using mongodb source in ssis (using c# driver). new mongodb , c#. when did not have nested documents, statements below worked me:
var query = query.and(query.or(query.gt("createdon",maxupdatedonbson), query.gt("updatedon", maxupdatedonbson)), query.or(query.lt("createdon", cutoffdate), query.lt("updatedon", cutoffdate)),query.in("testtype", testtypes) ); mongocursor<bsondocument> toreturn = collection.find(query);
now, got nested documents. able create java script, , works mongodb itself
db.test.aggregate( [ { $unwind : { path: "$items",includearrayindex: "arrayindex"} } , { $match: { $and: [ {$or: [ { createdon: { $gt: isodate("2015-11-22t00:00:00z")} }, {updatedon: { $gt: isodate("2015-11-22t00:00:00z") } } ] }, {$or: [ { createdon: { $lt: isodate("2016-05-09t00:00:00z")} }, {updatedon: { $lt: isodate("2016-05-09t00:00:00z") } } ] } ] } }] )
in c#, understand, have use aggregate instead of find cannot translate code c#. still have selection criteria , unwind.
can please help?
because there no collection template posted, i'm attaching snippet similar looking for. help?
var builder = builders<bsondocument>.filter; //and operator can used similar below using operator "&" or builder.and. var filter = builder.eq("state", "nj") | builder.eq("state", "co"); var filter2 = builder.eq("pop", 6033) | builder.eq("city", "nyc"); filter = builder.and(filter, filter2); var pipeline = grades.aggregate() .unwind(x => x["items"]) .match(filter); var list = pipeline.tolist(); foreach (var item in list) { //do }
Comments
Post a Comment