UE- -js-20141125
Function Trim (str)
{
// Remove the spaces at the beginning and end of str
Var temp1 = str. replace (/(^ \ s *) | (\ s * $)/g ,"");
// Remove the single quotation marks at the beginning and end of str
Var temp2 = temp1.replace (/(^ '*) | (' * $)/g ,"");
// Remove the double quotation marks at the beginning and end of str
Var temp3 = temp2.replace (/(^ "*) | (" * $)/g ,"");
Return temp3;
}
// Array grouping
Function count_str (text_all, str_f)
{
Var result = "";
Result = text_all.split (str_f );
// Return result. length-1;
Return result;
}
UltraEdit. activeDocument. findReplace. regExp = true;
Var str_f = "^ db ";
Var str_s = "^ select ";
// UltraEdit. activeDocument. bottom (); // jump to the end of the file.
// = Mongo. find =
UltraEdit.doc ument [0]. write ("\ n =============\ n ")
UltraEdit. activeDocument. top ();
UltraEdit. activeDocument. findReplace. find (str_f); // query the str_f string.
While (UltraEdit. activeDocument. isFound () // If the string to be queried is found, execute the following program
{
UltraEdit. activeDocument. selectLine ();
Line = UltraEdit. activeDocument. selection;
// UltraEdit. messageBox ("find:" + line );
// Var array = line. split (":"); // It is divided into arrays.
Var array = count_str (line ,":");
Var arr2 = array [0]. split ("{");
Var arr3 = array [1]. split ("}");
Var arr4 = arr2 [0]. split (".");
// UltraEdit. messageBox (arr4 [1] + "," + arr2 [1] + "," + arr3 [0]);
Var tab_name = arr4 [1];
Var key_name2 = arr2 [1];
Var key_name = Trim (key_name2)
Var key_value2 = arr3 [0];
Var key_value = Trim (key_value2)
Var Filed_0 = 'db. '+ tab_name + '. find ({"'+ key_name +'": "'+ key_value +'" },{ "logicalDel": 1 }). pretty ()';
// Var Filed_1 = 'db. '+ db_name +'. remove ({"'+ key_name +'": "'+ key_value + '"})';
// Var Filed_2 = 'db. '+ tab_name + '. update ({"'+ key_name +'": "'+ key_value +'"}, {$ set: {"logicalDel": NumberInt (1 )}})';
// UltraEdit. messageBox (Filed_0 + "\ n" + Filed_1 );
// UltraEdit. messageBox (Filed_2 );
UltraEdit.doc ument [0]. write (Filed_0 + "\ n ");
// UltraEdit.doc ument [0]. write (Filed_2 + "\ n ")
UltraEdit. activeDocument. findReplace. find (str_f );
}
UltraEdit.doc ument [0]. write ("\ n =============\ n ")
// = Mongo. update =
UltraEdit. activeDocument. top ();
UltraEdit. activeDocument. findReplace. find (str_f); // query the str_f string.
While (UltraEdit. activeDocument. isFound () // If the string to be queried is found, execute the following program
{
UltraEdit. activeDocument. selectLine ();
Line = UltraEdit. activeDocument. selection;
// UltraEdit. messageBox ("find:" + line );
// Var array = line. split (":"); // It is divided into arrays.
Var array = count_str (line ,":");
Var arr2 = array [0]. split ("{");
Var arr3 = array [1]. split ("}");
Var arr4 = arr2 [0]. split (".");
// UltraEdit. messageBox (arr4 [1] + "," + arr2 [1] + "," + arr3 [0]);
Var tab_name = arr4 [1];
Var key_name2 = arr2 [1];
Var key_name = Trim (key_name2)
Var key_value2 = arr3 [0];
Var key_value = Trim (key_value2)
// Var Filed_0 = 'db. '+ tab_name + '. find ({"'+ key_name +'": "'+ key_value +'" },{ "logicalDel": 1 }). pretty ()';
// Var Filed_1 = 'db. '+ db_name +'. remove ({"'+ key_name +'": "'+ key_value + '"})';
Var Filed_2 = 'db. '+ tab_name + '. update ({"'+ key_name +'": "'+ key_value +'"}, {$ set: {"logicalDel": NumberInt (1 )}})';
// UltraEdit. messageBox (Filed_0 + "\ n" + Filed_1 );
// UltraEdit. messageBox (Filed_2 );
// UltraEdit.doc ument [1]. write (Filed_0 + "\ n ");
UltraEdit.doc ument [0]. write (Filed_2 + "\ n ")
UltraEdit. activeDocument. findReplace. find (str_f );
}
// = Mysql. select =
UltraEdit.doc ument [0]. write ("\ n =============\ n ")
UltraEdit. activeDocument. top ();
UltraEdit. activeDocument. findReplace. find (str_s); // query the str_f string.
While (UltraEdit. activeDocument. isFound () // If the string to be queried is found, execute the following program
{
UltraEdit. activeDocument. selectLine ();
Line = UltraEdit. activeDocument. selection;
// UltraEdit. messageBox ("find:" + line );
Var arr = count_str (line ,"");
// UltraEdit. messageBox (arr [3] + "," + arr [5]);
Var table_name = Trim (arr [3]);
Var arr2 = count_str (arr [5], "= ");
// UltraEdit. messageBox (arr2 [0] + "," + arr2 [1]);
Var Column_name = Trim (arr2 [0]);
Var Column_value2 = Trim (arr2 [1]);
Var Column_value = count_str (Column_value2 ,"\"")
Var Filed_4 = 'select * from' + table_name + 'where' + Column_name + '= "' + Column_value [0] + '" \ G ';
// UltraEdit. messageBox (Filed_4 );
UltraEdit.doc ument [0]. write (Filed_4 + "\ n ")
UltraEdit. activeDocument. findReplace. find (str_s );
}
// = Mysql. update =
UltraEdit.doc ument [0]. write ("\ n =============\ n ")
UltraEdit. activeDocument. top ();
UltraEdit. activeDocument. findReplace. find (str_s); // query the str_f string.
While (UltraEdit. activeDocument. isFound () // If the string to be queried is found, execute the following program
{
UltraEdit. activeDocument. selectLine ();
Line = UltraEdit. activeDocument. selection;
// UltraEdit. messageBox ("find:" + line );
Var arr = count_str (line ,"");
// UltraEdit. messageBox (arr [3] + "," + arr [5]);
Var table_name = Trim (arr [3]);
Var arr2 = count_str (arr [5], "= ");
// UltraEdit. messageBox (arr2 [0] + "," + arr2 [1]);
Var Column_name = Trim (arr2 [0]);
Var Column_value2 = Trim (arr2 [1]);
Var Column_value = count_str (Column_value2 ,"\"")
Var Filed_4 = 'updat' + table_name + 'set LogicalDel = 1 where' + Column_name + '= "' + Column_value [0] + '";';
// UltraEdit. messageBox (Filed_4 );
UltraEdit.doc ument [0]. write (Filed_4 + "\ n ")
UltraEdit. activeDocument. findReplace. find (str_s );
}
UltraEdit.doc ument [0]. write ("commit; \ n ")