Writing out from aggregates in a loop does not work v5.1.7

Jase Kurasz shared this problem 5 years ago
Solved

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(

Replies (8)

photo
1

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.

  • NoSQLBooster Version
  • Operating System (Windows/Mac/Ubuntu):
  • MongoDB Version
  • Expected Behavior
  • Actual Behavior
  • How to Reproduce (Please attach sample JSON data)

photo
1
  • NoSQLBooster Version: 5.1.7
  • Operating System (Windows/Mac/Ubuntu): Mac Version 10.14.4
  • MongoDB Version: 3.4.20
  • Expected "a01"} and { _id:2, item: "b02"} records to collection1 and collection2
  • Actual /li>
  • How to Reproduce: see following code that i modified from one of your samples
  • 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);
    db.getCollection(collectionNames).aggregate(

photo
1

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);

db.bugRepro.aggregate(

photo
1

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

photo
1

I'm running on a macbook, do you have a .dmg?

photo
1

Looks like its fixed, thank you!

photo
1

Resolved in 5.1.8

Leave a Comment
 
Attach a file