Skip to content

Commit

Permalink
fix: Explicit indexFields on nextcloud queries
Browse files Browse the repository at this point in the history
The aim is to use an explicit indexFields whenever there's a where, without including the partialIndex fields which are calculated separately in cozy-client
  • Loading branch information
cballevre committed Aug 19, 2024
1 parent 4a35eae commit 143e97c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,12 @@ export const buildNextcloudFolderQuery: QueryBuilder<
buildNextcloudFolderQueryParams
> = ({ sourceAccount, path }) => ({
definition: () =>
Q('io.cozy.remote.nextcloud.files').where({
'cozyMetadata.sourceAccount': sourceAccount,
parentPath: path
}),
Q('io.cozy.remote.nextcloud.files')
.where({
'cozyMetadata.sourceAccount': sourceAccount,
parentPath: path
})
.indexFields(['cozyMetadata.sourceAccount', 'parentPath']),
options: {
as: `io.cozy.remote.nextcloud.files/sourceAccount/${
sourceAccount ?? 'unknown'
Expand All @@ -453,7 +455,7 @@ export const buildNextcloudShortcutQuery: QueryBuilder<
.partialIndex({
'cozyMetadata.createdByApp': 'nextcloud'
})
.indexFields(['cozyMetadata.createdByApp', 'cozyMetadata.sourceAccount'])
.indexFields(['cozyMetadata.sourceAccount'])
.limitBy(1),
options: {
as: `io.cozy.files/createdByApp/nextcloud/sourceAccount/${sourceAccount}`,
Expand Down Expand Up @@ -514,11 +516,13 @@ export const buildNextcloudTrashFolderQuery: QueryBuilder<
buildNextcloudTrashFolderQueryParams
> = ({ sourceAccount, path }) => ({
definition: () =>
Q('io.cozy.remote.nextcloud.files').where({
'cozyMetadata.sourceAccount': sourceAccount,
parentPath: path,
trashed: true
}),
Q('io.cozy.remote.nextcloud.files')
.where({
'cozyMetadata.sourceAccount': sourceAccount,
parentPath: path,
trashed: true
})
.indexFields(['cozyMetadata.sourceAccount', 'parentPath', 'trashed']),
options: {
as: `io.cozy.remote.nextcloud.files/sourceAccount/${
sourceAccount ?? 'unknown'
Expand Down

0 comments on commit 143e97c

Please sign in to comment.