Skip to content

Instantly share code, notes, and snippets.

@tvl83
Created July 30, 2017 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvl83/e14313cb602a4392de73530e015f8251 to your computer and use it in GitHub Desktop.
Save tvl83/e14313cb602a4392de73530e015f8251 to your computer and use it in GitHub Desktop.
obj: { title: /.*@followbtcnews.*/i,
'$or': [ { body: /.*@followbtcnews.*/i } ] }
stringify: {"title":{},"$or":[{"body":{}}]}
parsed: { title: {}, '$or': [ { body: {} } ] }
{ title: /.*@followbtcnews.*/i,
'$or': [ { body: /.*@followbtcnews.*/i } ] }
app.post('/mentions', function(req,res){
// console.log(req.body);
var titleRegex = ".*@"+req.body.username+".*";
var titleRegexObj = new RegExp(titleRegex, 'i');
var query = {
"title": titleRegexObj,
$or: [
{
"body": titleRegexObj
}
]
};
console.log("obj: ", query);
console.log("stringify: ", JSON.stringify(query));
console.log("parsed: ", JSON.parse(JSON.stringify(query)));
console.log(query);
res.json(query);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment