0

For example, I want execute count command like:

db.test.count()

or group?

How can do it in mongoose.js?

By the way, how can I execute aggregate command in mongoose? it seems doesn't have runCommand

hh54188
  • 14,887
  • 32
  • 113
  • 184

2 Answers2

0

Mongoose is built on the the "mongodb" nodejs driver. Therefore Mongoose's coding patterns generally look more like this driver than the Mongo CLI. In particular most calls are asynchronous and require a callback to get results. In addition to almypal's example in his comment here is an aggregate example.

mjhm
  • 16,497
  • 10
  • 44
  • 55
0

On the mongodb client you can use db.<collection>.find().cound() to accomplish it.

Ito
  • 2,167
  • 3
  • 23
  • 32