Add more default filters (#1955)

This commit is contained in:
Laurent Nguyen 2024-09-05 07:16:48 +02:00 committed by GitHub
parent e8a5658799
commit 4296b5ae02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -516,7 +516,10 @@ export interface IDocumentsTabComponentProps {
const getUniqueId = (collection: ViewModels.CollectionBase): string => `${collection.databaseId}-${collection.id()}`; const getUniqueId = (collection: ViewModels.CollectionBase): string => `${collection.databaseId}-${collection.id()}`;
const defaultSqlFilters = ['WHERE c.id = "foo"', "ORDER BY c._ts DESC", 'WHERE c.id = "foo" ORDER BY c._ts DESC']; const getDefaultSqlFilters = (partitionKeys: string[]) =>
['WHERE c.id = "foo"', "ORDER BY c._ts DESC", 'WHERE c.id = "foo" ORDER BY c._ts DESC', "ORDER BY c._ts ASC"].concat(
partitionKeys.map((partitionKey) => `WHERE c.${partitionKey} = "foo"`),
);
const defaultMongoFilters = ['{"id":"foo"}', "{ qty: { $gte: 20 } }"]; const defaultMongoFilters = ['{"id":"foo"}', "{ qty: { $gte: 20 } }"];
// Export to expose to unit tests // Export to expose to unit tests
@ -1800,7 +1803,7 @@ export const DocumentsTabComponent: React.FunctionComponent<IDocumentsTabCompone
<datalist id={`filtersList-${getUniqueId(_collection)}`}> <datalist id={`filtersList-${getUniqueId(_collection)}`}>
{addStringsNoDuplicate( {addStringsNoDuplicate(
lastFilterContents, lastFilterContents,
isPreferredApiMongoDB ? defaultMongoFilters : defaultSqlFilters, isPreferredApiMongoDB ? defaultMongoFilters : getDefaultSqlFilters(partitionKeyProperties),
).map((filter) => ( ).map((filter) => (
<option key={filter} value={filter} /> <option key={filter} value={filter} />
))} ))}