balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

Waterline, sum() mongodb adapter -> The 'cursor' option is required. #6795

Open mkbrdigital opened 5 years ago

mkbrdigital commented 5 years ago

Sails@lastest-version Node@stable-version

my action:

module.exports = {
  friendlyName: 'Total',

  description: 'Total finance.',

  inputs: {
    project: {
      type: 'string',
      required: true
    }
  },

  exits: {},

  fn: async function({ project }, exits) {
    const listTotalFinances = await Finance.sum('value').where({
      project
    });
    if (listTotalFinances) {
      return exits.success(listTotalFinances);
    }
  }
};

Error info:

Sending 500 ("Server Error") response: 
 AdapterError: Unexpected error from database adapter: The 'cursor' option is required, except for aggregate with the explain argument
    at Object.fn..

Im using MongoDB Atlas.

sailsbot commented 5 years ago

@mkbrdigital Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

johnabrams7 commented 5 years ago

Hey @mkbrdigital , which version of Sails, Mongo, and the sails-mongo adapter are you using for this one?

This may be more related to the Mongo side as well. Have you tried adding {cursor:{}} to you aggregation pipeline? Experiences can still vary based on which version of Mongo is being used as well.

steinathan commented 5 years ago

using mongo atlas, i could not replicate this issue with a fresh installation of a sails app, though i faked my data, the request did not complete, it timed-out ERR_EMPTY_RESPONSE , maybe this may be related with the driver of just an internal bug with .sum()

whichking commented 5 years ago

Hi, @navicstein! Which version of sails-mongo are you using?

Tarrask commented 5 years ago

this issue look like the issue #4557.

The master version of sails-mongo fix it, but it is not yet published on npm.