nswbmw / koa-mongo

MongoDB middleware for koa, support connection pool.
145 stars 31 forks source link

Retrieve bulk data #10

Closed ickyrr closed 7 years ago

ickyrr commented 8 years ago

Hello, I'm new in KoaJS. I've been looking for a mongodb module, and I think this is a good one. Just need a little help, though. How can I retrieve multiple documents from mongo and display it? I'm using swig module for HTML template, koa router for routing (if this helps).

Thanks a lot.

Laoujin commented 7 years ago

I just ran into this:

this.body = yield this.mongo.db('db').collection('col').find().toArray();

Without the .toArray(), I got the following error:

 TypeError: You may only yield a function, promise, generator, array, or object, but the following object was passed: "[object Object]"
lduoduo commented 7 years ago

Without the .toArray(), I got the following error:

TypeError: You may only yield a function, promise, generator, array, or object, but the following object was passed: "[object Object]" 。。。。。i just met this..