@xuda.io/drive_module 1.1.886 → 1.1.888

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.
Files changed (2) hide show
  1. package/index.js +45 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -116,6 +116,51 @@ exports.get_drive_files = async function (req) {
116
116
  opt.selector.file_path = req.path;
117
117
  }
118
118
 
119
+ if (search_string) {
120
+ tags_query = search_string
121
+ .split(" ")
122
+ .filter((e) => e.includes(":"))
123
+ .reduce(
124
+ (ret, val) => {
125
+ var tagKey = val.split(":")[0];
126
+ var tagVal = val.split(":")[1];
127
+
128
+ if (tagKey === "tag") {
129
+ tags.push(tagVal);
130
+ }
131
+
132
+ if (tagKey === "name") {
133
+ ret.$or.push({ originalname: { $regex: `(?i)${tagVal}` } });
134
+ }
135
+
136
+ return ret;
137
+ },
138
+ {
139
+ $or: [],
140
+ }
141
+ );
142
+
143
+ var new_search = search_string
144
+ .split(" ")
145
+ .filter((e) => !e.includes(":"))
146
+ .filter((e) => e)
147
+ .join(" ");
148
+
149
+ tags_query.$or = [
150
+ ...tags_query.$or,
151
+ {
152
+ ocr: {
153
+ $regex: `(?i)${new_search}`,
154
+ },
155
+ },
156
+ {
157
+ originalname: {
158
+ $regex: `(?i)${new_search}`,
159
+ },
160
+ },
161
+ ];
162
+ }
163
+
119
164
  validate_drive_type(drive_type);
120
165
 
121
166
  function formatBytes(bytes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.886",
3
+ "version": "1.1.888",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {