Answer the question
In order to leave comments, you need to log in
MongoDB how to correctly compose a query consisting of many parameters?
Actually, it is necessary to organize a search, but it is not entirely clear how to do this if there are 13 parameters, besides, any of them may not be. Obviously, we cannot consider all options. No, in general we can, but it’s scary to imagine how long it will take, and it’s not at all clear how to support it. So, what is the algorithm to solve the problem? How to make such requests? I write in PHP.
Answer the question
In order to leave comments, you need to log in
Take all the parameters that came in, for example 5 out of 13, and form the request object:
JSON
{
param1:val1,
param2: {$exists: true}
$or: [{param3:val3}, {param4:val4}]
}
Imagine that you are working with arrays of different nesting depths. This makes it easier to understand which approach to use.
Here, the process is available:
www.codeisart.ru/blog/creating-parsing-json-data-php
Documentation:
php.net/manual/ru/function.json-encode.php
php.net/manual/ru/ function.json-decode.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question