@xuda.io/drive_module 1.1.851 → 1.1.853
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +26 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1721,38 +1721,48 @@ exports.search_drive_files = async function (req) {
|
|
|
1721
1721
|
|
|
1722
1722
|
const sort_by_obj = { name: "originalname", date: "date_created" };
|
|
1723
1723
|
|
|
1724
|
-
const protected_tags = ["tag", "name"];
|
|
1724
|
+
const protected_tags = ["tag:", "name:"];
|
|
1725
1725
|
|
|
1726
1726
|
if (protected_tags.includes(search_string)) {
|
|
1727
1727
|
// var og_search = ""
|
|
1728
|
-
let
|
|
1728
|
+
let tags_query = search_string.split(" ").filter(e => e.includes(':')).reduce((ret, val) => {
|
|
1729
1729
|
var tagKey = val.split(":")[0];
|
|
1730
1730
|
var tagVal = val.split(":")[1];
|
|
1731
1731
|
|
|
1732
1732
|
if (!ret[tagKey]) ret[tagKey] = [];
|
|
1733
1733
|
|
|
1734
1734
|
if (tagVal) {
|
|
1735
|
-
|
|
1735
|
+
if(tagKey === 'tags'){
|
|
1736
|
+
|
|
1737
|
+
ret[tagKey].push({tags: { $in:tagVal} });
|
|
1738
|
+
}
|
|
1739
|
+
else{
|
|
1740
|
+
ret[tagKey].push({ $or: {$regex:tagVal} });
|
|
1741
|
+
}
|
|
1736
1742
|
} else {
|
|
1737
1743
|
og_search += og_search;
|
|
1738
1744
|
}
|
|
1739
1745
|
|
|
1740
|
-
// $or: [
|
|
1741
|
-
// {
|
|
1742
|
-
// ocr: {
|
|
1743
|
-
// $regex: `(?i)${req.search_string}`,
|
|
1744
|
-
// },
|
|
1745
|
-
// },
|
|
1746
|
-
// {
|
|
1747
|
-
// originalname: {
|
|
1748
|
-
// $regex: `(?i)${req.search_string}`,
|
|
1749
|
-
// },
|
|
1750
|
-
// },
|
|
1751
|
-
// ],
|
|
1752
|
-
// };
|
|
1753
1746
|
|
|
1754
1747
|
return ret;
|
|
1755
1748
|
}, {});
|
|
1749
|
+
|
|
1750
|
+
var new_search = search_string.split(" ").filter(e => !e.includes(':')).filter(e=>e).join(' ')
|
|
1751
|
+
tags_query.$or= [
|
|
1752
|
+
{
|
|
1753
|
+
ocr: {
|
|
1754
|
+
$regex: `(?i)${new_search}`,
|
|
1755
|
+
},
|
|
1756
|
+
},
|
|
1757
|
+
{
|
|
1758
|
+
originalname: {
|
|
1759
|
+
$regex: `(?i)${new_search}`,
|
|
1760
|
+
},
|
|
1761
|
+
},
|
|
1762
|
+
],
|
|
1763
|
+
|
|
1764
|
+
|
|
1765
|
+
|
|
1756
1766
|
}
|
|
1757
1767
|
try {
|
|
1758
1768
|
validate_drive_type(drive_type);
|