🛠️Speed up "shared with me" query (#381)
This commit is contained in:
+12
@@ -40,6 +40,7 @@ export function buildSelectQuery<Entity>(
|
||||
findOptions = secureOperators(transformValueToDbString, findOptions, entityType, options);
|
||||
where = buildComparison(where, findOptions);
|
||||
where = buildIn(where, findOptions);
|
||||
where = buildNin(where, findOptions);
|
||||
|
||||
return where;
|
||||
}
|
||||
@@ -67,3 +68,14 @@ export function buildIn(where: any, options: FindOptions = {}): any {
|
||||
|
||||
return where;
|
||||
}
|
||||
|
||||
export function buildNin(where: any, options: FindOptions = {}): any {
|
||||
if (options.$nin) {
|
||||
options.$nin.forEach(element => {
|
||||
if (!where[element[0]]) where[element[0]] = {};
|
||||
where[element[0]]["$nin"] = element[1];
|
||||
});
|
||||
}
|
||||
|
||||
return where;
|
||||
}
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ export type FindOptions = {
|
||||
* The $in operator selects the documents where the value of a field equals any value in the specified array
|
||||
*/
|
||||
$in?: inType[];
|
||||
$nin?: inType[];
|
||||
$like?: likeType[];
|
||||
};
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ export default class StorageService extends TdriveService<StorageAPI> implements
|
||||
});
|
||||
} else {
|
||||
logger.info("Using 'local' connector for storage.");
|
||||
const defaultHomeDir = this.configuration.get<string>("local.path");
|
||||
if (defaultHomeDir) this.homeDir = `${defaultHomeDir}`;
|
||||
// const defaultHomeDir = this.configuration.get<string>("local.path");
|
||||
// if (defaultHomeDir) this.homeDir = `${defaultHomeDir}`;
|
||||
logger.trace(`Home directory for the storage: ${this.homeDir}`);
|
||||
}
|
||||
logger.info(
|
||||
|
||||
@@ -986,6 +986,7 @@ export class DocumentsService {
|
||||
]
|
||||
: []),
|
||||
],
|
||||
$nin: [...(options.onlyDirectlyShared ? [["creator", [context.user.id]] as inType] : [])],
|
||||
$lte: [
|
||||
...(options.last_modified_lt
|
||||
? [["last_modified", options.last_modified_lt] as comparisonType]
|
||||
|
||||
Reference in New Issue
Block a user