@xuda.io/drive_module 1.1.885 → 1.1.887
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 +48 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -99,6 +99,8 @@ exports.get_drive_files = async function (req) {
|
|
|
99
99
|
} = req;
|
|
100
100
|
|
|
101
101
|
let { tags = [] } = req;
|
|
102
|
+
let tags_query = {};
|
|
103
|
+
const sort_by_obj = { name: "originalname", date: "date_created" };
|
|
102
104
|
|
|
103
105
|
try {
|
|
104
106
|
let opt = {
|
|
@@ -114,6 +116,52 @@ exports.get_drive_files = async function (req) {
|
|
|
114
116
|
opt.selector.file_path = req.path;
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
if (search_string) {
|
|
120
|
+
// var og_search = ""
|
|
121
|
+
tags_query = search_string
|
|
122
|
+
.split(" ")
|
|
123
|
+
.filter((e) => e.includes(":"))
|
|
124
|
+
.reduce(
|
|
125
|
+
(ret, val) => {
|
|
126
|
+
var tagKey = val.split(":")[0];
|
|
127
|
+
var tagVal = val.split(":")[1];
|
|
128
|
+
|
|
129
|
+
if (tagKey === "tag") {
|
|
130
|
+
tags.push(tagVal);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (tagKey === "name") {
|
|
134
|
+
ret.$or.push({ originalname: { $regex: `(?i)${tagVal}` } });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return ret;
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
$or: [],
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
var new_search = search_string
|
|
145
|
+
.split(" ")
|
|
146
|
+
.filter((e) => !e.includes(":"))
|
|
147
|
+
.filter((e) => e)
|
|
148
|
+
.join(" ");
|
|
149
|
+
|
|
150
|
+
tags_query.$or = [
|
|
151
|
+
...tags_query.$or,
|
|
152
|
+
{
|
|
153
|
+
ocr: {
|
|
154
|
+
$regex: `(?i)${new_search}`,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
originalname: {
|
|
159
|
+
$regex: `(?i)${new_search}`,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
|
|
117
165
|
validate_drive_type(drive_type);
|
|
118
166
|
|
|
119
167
|
function formatBytes(bytes) {
|