0

I'm designing a custom ODM and have model classes for each collection document. The model classes return a modified document result (eg: removes password field from user)

I've faced a frustrating problem that I'm unsure on how to solve effectively.

The mongodb collection find function returns a cursor. I want that cursor to return a modified forEach and toArray based on the Model's modified document result. How should I go about this?

Notes:

If it helps, I come from a Laravel PHP MySQL background

mateos
  • 1,405
  • 1
  • 17
  • 26
  • you can warp the driver class with your class and then for find return to array instead of the cursor – Amit Wagner Dec 17 '17 at 15:54
  • @AmitWagner yes but the reason the cursor exists is to not over-use RAM It let's you access documents in chunks – mateos Dec 18 '17 at 04:13
  • well that depends on your data. if you need to bring alot of large document then use the cursor stream but for most cases you wont need it. also you should you projection to bring only the content you need – Amit Wagner Dec 18 '17 at 07:06

0 Answers0