loopback icon indicating copy to clipboard operation
loopback copied to clipboard

like operator with long string in mongodb

Open makersu opened this issue 11 years ago • 1 comments

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)
});

makersu avatar Dec 12 '14 10:12 makersu

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' } }

makersu avatar Dec 19 '14 06:12 makersu