FTS simplifications
This commit is contained in:
@@ -215,6 +215,20 @@ export function applyQueryNoFilterKV(
|
||||
allItems[i].value = newRec;
|
||||
}
|
||||
}
|
||||
if (query.distinct) {
|
||||
// Remove duplicates
|
||||
const valueSet = new Set<string>();
|
||||
const uniqueItems: KV[] = [];
|
||||
for (const item of allItems) {
|
||||
const value = JSON.stringify(item.value);
|
||||
if (!valueSet.has(value)) {
|
||||
valueSet.add(value);
|
||||
uniqueItems.push(item);
|
||||
}
|
||||
}
|
||||
allItems = uniqueItems;
|
||||
}
|
||||
|
||||
if (query.limit) {
|
||||
const limit = evalQueryExpression(query.limit, {}, functionMap);
|
||||
if (allItems.length > limit) {
|
||||
|
||||
@@ -66,6 +66,7 @@ export type Query = {
|
||||
select?: Select[];
|
||||
limit?: QueryExpression;
|
||||
render?: string;
|
||||
distinct?: boolean;
|
||||
};
|
||||
|
||||
export type KvQuery = Omit<Query, "querySource"> & {
|
||||
|
||||
Reference in New Issue
Block a user