Closed marcoriesco closed 9 years ago
Because the db.collection.find() method in MongoDB performs an exact match. Have a look at: http://stackoverflow.com/questions/3305561/how-to-query-mongodb-with-like
Before you go searching hours here .. with Restheart I can not do a search , for example a title , with the partial letters ? Only with the full title ?
The filter query parameter is a mongodb query where you can use any mongodb operator.
In your case you can use the $regex operator:
/api/posts?filter={'title': {'$regex': '(?i)^Teste.*'}}
The i option performs a case-insensitive match for documents with title value that starts with "Test".
Of course, you can also build more complex queries, just for example:
/api/posts?filter={'$and': [{'title': {'$regex": "(?i)^Test.*'}, {'publish_date':{'$gte': {'$date': '2015-09-04T08:00:00Z' }}}]}
That selects documents with title starting with Test and published (assuming that field existing) starting from 4/9/2015, 8AM
also refer to the documentation: query documents section
Muito Obrigado!
Thanks very mutch :)
if /api/posts?filter={'title': "Teste de postagem"} - Returned
if /api/posts?filter={'title': "Teste"} - Not returned anything
Why?