loopback
loopback copied to clipboard
like operator with long string in mongodb
When use like operator, if the length of query string too long(>64 chars?) will find nothing with mongodb.
var where={ "where": { "url":{"like":"http://ookon_test001.nuweb.com/Site/wheeg7/Forum/forum_view.php?mode=far&path=GROUP_NEWS/&f=2014113&i=1"} } }
Numessage.find( where,function(err,numessages){
cb(err,numessages)
});
my solution: 1.need replace '?' to '\?' 2.seems like 'http://mmookon_test001.nuweb.cc/....%" doesn't work, so add '^' at the beginning of the query string to find by 'startwith' url
urlQueryString.replace(/\?/g, '\\\?');
urlQueryString = '^'+urlQueryString;
...
{ url: { like: '^http://mmookon_test001.nuweb.cc/Site/wheeg7/Forum/forum_view.php\\?mode=far&path=GROUP_NEWS/&f=2014113&i=1' } }