flash-oss / node_acl

Access control lists for node applications
MIT License
63 stars 9 forks source link

Missing index on `key` property on Mongodb #4

Closed gkampitakis closed 3 years ago

gkampitakis commented 3 years ago

I created an issue to the original repository just in case someone has the same issue. What was noticed is that the library creates an index https://github.com/flash-oss/node_acl/blob/966d079e3a2cda9a8243400e29fde857b0349c11/lib/mongodb-backend.js#L145 and then in the case of the useSingle=false we are not using this index as we are querying with just the key meaning we are not using the index resulting to slow queries. Maybe the index could respect the useSingle flag and create the correct index.

https://github.com/flash-oss/node_acl/blob/966d079e3a2cda9a8243400e29fde857b0349c11/lib/mongodb-backend.js#L121

koresar commented 3 years ago

Sound like a good idea. Would you please a PR? We love PRs!

gkampitakis commented 3 years ago

I am happy to 😄 , I will try to work on it today and send a pr

koresar commented 3 years ago

Thanks! Sorry for the delay. PR reviewed, merged, published as v2.0.1