Writing out from aggregates in a loop does not work v5.1.7
in the below example lets say I have a "mainDB" that consits of two documents with a field1 containing a string guid. If i try to run this code below to put those docs into 2 new collections it does not work.
var dict = {}
dict['collection1'] = ["zzPiUErfOJIRCC5bOiCjEmbr3IwgIzVK", "zviZyfPAyNib6W0yUCxLbN8gjjp0HEUf"]
dict['collection2'] = ["zzPiUErfOJIRCC5bOiCjEmbr3IwgIzVK", "zviZyfPAyNib6W0yUCxLbN8gjjp0HEUf"]
Object.keys(dict).forEach(function(key) {
// create the collection
db.createCollection(key);
// clear it out
db.getCollection(key).remove({});
// write out results of aggregate to the collection
db.getCollection('mainDB').aggregate([{$match: {field1: {$in: dict[key]}}}, {$out: key}]);
}
In fact I noticed that even trying to do just the following this will work BUT if i have any code after this then it will not write out to that collection
// create the collection
db.createCollection('collection3');
// clear it out
db.getCollection('collection3').remove({});
// write out results of aggregate to the collection
db.getCollection('mainDB').aggregate([{$match: {field1: {$in: ["zzPiUErfOJIRCC5bOiCjEmbr3IwgIzVK", "zviZyfPAyNib6W0yUCxLbN8gjjp0HEUf"]}}}, {$out: 'collection3'}]);
The same problem
I don't quite understand your description, can you give the complete replay steps by following the list below?
Thanks for opening your issue here! If you're reporting a bug, please make sure you include steps to reproduce it.
I don't quite understand your description, can you give the complete replay steps by following the list below?
Thanks for opening your issue here! If you're reporting a bug, please make sure you include steps to reproduce it.
use NoSQLBoosterSamples print(`prepare test data`); db.bugRepro.drop(); db.bugRepro.insert([ { _id:1, item: "a01"}, { _id:2, item: "b02"}, { _id:3, item: "c03"}, { _id:4, item: "d04"}, { _id:5, item: "e05"}, ]); // nothing is added to collection 1 or 2 var collectionNames = ["testCollection1", "testCollection2"]; for(var i = 0; i < collectionNames.length; i++) { db.createCollection(collectionNames[i]); db.getCollection(collectionNames[i]).aggregate([{$match: {item: {$in: ["a01", "b02"]}}}, {$out: collectionNames[i]}]); }use NoSQLBoosterSamples print(`prepare test data`); db.bugRepro.drop(); db.bugRepro.insert([ { _id:1, item: "a01"}, { _id:2, item: "b02"}, { _id:3, item: "c03"}, { _id:4, item: "d04"}, { _id:5, item: "e05"}, ]); // nothing is added to collection 1 or 2 var collectionNames = ["testCollection1", "testCollection2"]; for(var i = 0; i < collectionNames.length; i++) { db.createCollection(collectionNames[i]); db.getCollection(collectionNames[i]).aggregate([{$match: {item: {$in: ["a01", "b02"]}}}, {$out: collectionNames[i]}]); }sorry the above code is wrong, this is what i meant to put
print(`prepare test data`); db.bugRepro.drop(); db.bugRepro.insert([ { _id:1, item: "a01"}, { _id:2, item: "b02"}, { _id:3, item: "c03"}, { _id:4, item: "d04"}, { _id:5, item: "e05"}, ]); // nothing is added to collection 1 or 2 var collectionNames = ["testCollection1", "testCollection2"]; for(var i = 0; i < collectionNames.length; i++) { db.createCollection(collectionNames[i]); db.bugRepro.aggregate([{$match: {item: {$in: ["a01", "b02"]}}}, {$out: collectionNames[i]}]); } // note that if this print line is not here then collection 2 will have the documents in it but with this print neither do print("finished");sorry the above code is wrong, this is what i meant to put
print(`prepare test data`); db.bugRepro.drop(); db.bugRepro.insert([ { _id:1, item: "a01"}, { _id:2, item: "b02"}, { _id:3, item: "c03"}, { _id:4, item: "d04"}, { _id:5, item: "e05"}, ]); // nothing is added to collection 1 or 2 var collectionNames = ["testCollection1", "testCollection2"]; for(var i = 0; i < collectionNames.length; i++) { db.createCollection(collectionNames[i]); db.bugRepro.aggregate([{$match: {item: {$in: ["a01", "b02"]}}}, {$out: collectionNames[i]}]); } // note that if this print line is not here then collection 2 will have the documents in it but with this print neither do print("finished");Thank you for your feedback.
We have worked out a new test build to resolve this issue, please download and give it a try.
https://nosqlbooster.com/s3/download/releasesv5/nosqlbooster4mongo-5.1.8-beta.2.exe
Thank you for your feedback.
We have worked out a new test build to resolve this issue, please download and give it a try.
https://nosqlbooster.com/s3/download/releasesv5/nosqlbooster4mongo-5.1.8-beta.2.exe
I'm running on a macbook, do you have a .dmg?
I'm running on a macbook, do you have a .dmg?
Sorry, I made a mistake.
MacOS: https://nosqlbooster.com/s3/download/releasesv5/nosqlbooster4mongo-5.1.8-beta.2.dmg
Sorry, I made a mistake.
MacOS: https://nosqlbooster.com/s3/download/releasesv5/nosqlbooster4mongo-5.1.8-beta.2.dmg
Looks like its fixed, thank you!
Looks like its fixed, thank you!
Resolved in 5.1.8
Resolved in 5.1.8
Replies have been locked on this page!