0

I am trying to build advance search functionality. I want to convert the input string into mongodb query format.

for example, the input

'status = confirmed AND (assignee = xyz OR priority = low)'

Should be converted to output:

{
  and : [{
    status : 'confirmed'  
  }, {
    or: [
      {assignee: xyz},
      {priority: low}
    ]
  }]
}
4
  • Will there be nested parenthesis? (assignee = xyz OR (priority = low AND prop = 100))
    – adiga
    Commented Feb 6, 2019 at 9:43
  • 2
    Post the code that you attempted. Commented Feb 6, 2019 at 9:45
  • @adiga - yes there is nested parenthesis.
    – SJain
    Commented Feb 6, 2019 at 13:26
  • @PrerakSola - I have not attempted for nesting query. I am sharing the code for flat query - codeshare.io/a3qgp6
    – SJain
    Commented Feb 6, 2019 at 13:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.