Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1398

$out doesn't take effect

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Environment:
      driver 3.0.2
      mongo 3.6.2

      The $out stage doesn't take effect unless you call certain functions on the cursor afterwards (next and toArray are the ones I've checked).

      I would expect this to work but the new collection is NOT created:

      db.collection('names')
        .aggregate([
          { $match: {} }, { $limit: 1 },
          { $out: 'newNames' }
        ], (err, cursor) => {
          callback();
        });
      

      But if I do the same thing and call toArray on the cursor (which returns an empty array as expected), the new collection IS created:

      db.collection('names')
        .aggregate([
          { $match: {} }, { $limit: 1 },
          { $out: 'newNames' }
        ], (err, cursor) => {
          cursor.toArray(function (err, documents) {
            console.log(documents);
            callback();
          });
        });
      

      I looked at the test to make sure I was calling it correctly but the test doesn't check if the new collection has been created, only that it doesn't return any documents. It also passes out as an option but that's not listed in the docs (nor did it work when I tried it). See aggregation_tests.js line 624.

            Assignee:
            Unassigned Unassigned
            Reporter:
            adanilev Alex Danilevsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: