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
function textbraceTrim(text){ | |
let trimed = text; | |
if(text !== null && text !== '') { | |
let start_index = text.indexOf('('); | |
let end_index = text.indexOf(')') + 1; | |
trimed = text.substring(0, start_index) + text.substring(end_index, text.length); | |
trimed = trimed.trim(); | |
} | |
return trimed; | |
} |
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
var korean = [ "다", "나", "가" ]; | |
function ascending ( a , b ) { | |
return a.localeCompare ( b ); | |
} | |
function descending ( a , b ) { | |
return b.localeCompare ( a ); | |
} |
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
About the WTFPL | |
WTFPL – Do What the Fuck You Want to Public License | |
Posted December 26th, 2012 by Sam Hocevar. | |
The Do What The Fuck You Want To Public License (WTFPL) is a free software license. | |
There is a long ongoing battle between GPL zealots and BSD fanatics, about which license type is the most free of the two. In fact, both license types have unacceptable obnoxious clauses (such as reproducing a huge disclaimer that is written in all caps) that severely restrain our freedoms. The WTFPL can solve this problem. |
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
let bulk = db.collection('myCollection').initializeOrderedBulkOp(); | |
for(let i=0; i < arr.length; i++){ | |
bulk.find( {findData: arr[i]} ).upsert().updateOne( | |
{ | |
$set: { modData: 'yolo' } | |
} | |
); | |
} | |
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
var arr = []; | |
// for any falsy value (0, "", NaN, null, undefined, or of course, false): | |
if (!myarray[0]){ | |
// isEmpty | |
} else { | |
// notEmpty | |
} |
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
db.collection('myCollection').find( { 'findData': { $exists: true } }).toArray( (err, results) => {}); |
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
db.collection.find({ "findData": "blabla" }).sort({"orderData": -1}).limit(1) |
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
var n = 5; | |
var nn = [n]; | |
for (var i = 1; i < 5; i++) { | |
nn.push(nn[0] - i); | |
} | |
console.log(JSON.stringify(nn)); |
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
db.collection('my_collection').find( { 'findData': 'MorefindOption', | |
$or : [ | |
{ 'name' : { $regex: 'searchWord' , $options: 'ix' } }, | |
{ 'adress' : { $regex: 'searchWord' , $options: 'ix' } } | |
] }) | |
// more option available at google search -> mongodb regex option | |
// -> in mongo cli { name : /.*searchWord.*/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
db.collection.aggregate( [ | |
{ $match: { 'dept': "service", 'condition': '0' } }, | |
{ $group: { _id: { first: "$distinct_col1", second: "$distinct_col1" }, // distinct option | |
id_tag : { $min: "$tag" }, // projection | |
count: { $sum:1 } // group count | |
} | |
}, | |
{ $sort: { '_.id.regdate': 1 }}, // make sure sort by group id // 1 asc | |
{ $skip: 0 }, | |
{ $limit: 5 }, |
OlderNewer