leodinas-hao / mongoose-query-parser

Convert url query string to MongooseJs friendly query object including advanced filtering, sorting, population, string template, type casting and many more...
MIT License
68 stars 17 forks source link

Query parameter conflicts #1

Closed olicooper closed 6 years ago

olicooper commented 6 years ago

I have been implementing this library in to an Express project that serves a RESTful API to the user. I have run in to a problem where I'm getting Cannot create property '$ne' on string 'admin@example.com' and it points to mongoose-query-parser\lib\ index.js:134:14 and index.js:152:33. I pass in email=admin@example.com&email!=admin@example.com and I know this is a bit strange but I don't know the users query and I need to stop them returning results with a particular email. I this something that can be fixed easily? Thanks.

leodinas-hao commented 6 years ago

Thanks for your feedback @olicooper Are you expecting your query string to be parsed as below? However, it seems not really making sense to me.

{
  email: {
    $eq: "admin@example.com",
    $ne: "admin@example.com"
  }
}

Would one of the conditions solve your issue? But not both as you will get no return.