Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongodb node - aggregates documentation #40

Open
paultanner opened this issue Feb 22, 2016 · 0 comments
Open

mongodb node - aggregates documentation #40

paultanner opened this issue Feb 22, 2016 · 0 comments

Comments

@paultanner
Copy link

About the only doc on aggregates on mongodb via node-red is in a closed issue.
It would be useful to have some code examples.

I am making a big assumption: that the mongodb option in node-red on Bluemix is supported for use with mongodb on Compose and with the Time Series on Bluemix.

I think it should/ may be possible to provide a group parameter (without which AFAIK aggregates can't happen). I guess this could be done with an array or in a function.
so I tried adding this to my function:

msg.group={"value":{"$sum":"$value"},"count":{"$sum":1}}

so the payload going into the aggregate option of the mongo node is:

{
  "topic": "", 
  "payload": { "id": 1234 },
  "_msgid": "6ee585c5.911a7c",
  "projection": { "pcfree": 1, "_id": 0 },
  "group": {
    "value": { "$sum": "$pcfree" },
    "count": { "$sum": 1 }
  }
}

This doesn't seem to be a good guess. I get:

MongoError: Index: 0, Size: 0

The same thing happens without the $ signs that we need for mongo cli.

I think I should stop guessing and see if anyone has a suitable code example for aggregates, maybe to add to the documentation for the mongodb node help text.

Also, if my assumptions about mongo and time series are wrong it would be great to know.

Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant