Created
July 30, 2017 00:59
-
-
Save tvl83/e14313cb602a4392de73530e015f8251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj: { title: /.*@followbtcnews.*/i, | |
'$or': [ { body: /.*@followbtcnews.*/i } ] } | |
stringify: {"title":{},"$or":[{"body":{}}]} | |
parsed: { title: {}, '$or': [ { body: {} } ] } | |
{ title: /.*@followbtcnews.*/i, | |
'$or': [ { body: /.*@followbtcnews.*/i } ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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