Middleware for query / find functions

39 views
Skip to first unread message

Thomas Forrer

unread,
Nov 3, 2014, 3:25:09 PM11/3/14
to mongoo...@googlegroups.com
I am building an application, where I need to intercept all queries that are being made against the database for a particular model. Depending on certain states (executing user, etc.) I need to modify the query and add additional conditions to it. Is there already a way of doing something like that in mongoose? I figured middleware would be a good place to start, but it seems middleware only provides interfaces to intercept CRUD operations. 

Why does middleware only allow intercepting CRUD operations, but not query operations?

I am quite new to mongoDB and mongoose, so I would really appreciate some help from more experienced developers with this problem. 

I implemented a prototype, where I override the model's find function to allow for intercepting the query. Are there any plans to implement such a feature in mongoose in the near future? Do you see any architectural problems for my application in using this approach?

Thanks for your help!

Reply all
Reply to author
Forward
0 new messages