immich/server/src/queries/sync.repository.sql
Zack Pollard fa26d0de33
refactor: new helper methods that work for all sync queries (#20690)
refactor: new helper methods that work for all sync queries
2025-08-06 08:34:12 -04:00

1051 lines
22 KiB
SQL

-- NOTE: This file is auto generated by ./sql-generator
-- SyncRepository.album.getCreatedAfter
select
"albumsId" as "id",
"createId"
from
"album_user"
where
"usersId" = $1
and "createId" >= $2
and "createId" < $3
order by
"createId" asc
-- SyncRepository.album.getDeletes
select
"id",
"albumId"
from
"album_audit" as "album_audit"
where
"album_audit"."id" < $1
and "album_audit"."id" > $2
and "userId" = $3
order by
"album_audit"."id" asc
-- SyncRepository.album.getUpserts
select distinct
on ("album"."id", "album"."updateId") "album"."id",
"album"."ownerId",
"album"."albumName" as "name",
"album"."description",
"album"."createdAt",
"album"."updatedAt",
"album"."albumThumbnailAssetId" as "thumbnailAssetId",
"album"."isActivityEnabled",
"album"."order",
"album"."updateId"
from
"album" as "album"
left join "album_user" as "album_users" on "album"."id" = "album_users"."albumsId"
where
"album"."updateId" < $1
and "album"."updateId" > $2
and (
"album"."ownerId" = $3
or "album_users"."usersId" = $4
)
order by
"album"."updateId" asc
-- SyncRepository.albumAsset.getBackfill
select
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."libraryId",
"album_asset"."updateId"
from
"album_asset" as "album_asset"
inner join "asset" on "asset"."id" = "album_asset"."assetsId"
where
"album_asset"."updateId" < $1
and "album_asset"."updateId" <= $2
and "album_asset"."updateId" >= $3
and "album_asset"."albumsId" = $4
order by
"album_asset"."updateId" asc
-- SyncRepository.albumAsset.getUpdates
select
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."libraryId",
"asset"."updateId"
from
"asset" as "asset"
inner join "album_asset" on "album_asset"."assetsId" = "asset"."id"
inner join "album" on "album"."id" = "album_asset"."albumsId"
left join "album_user" on "album_user"."albumsId" = "album_asset"."albumsId"
where
"asset"."updateId" < $1
and "asset"."updateId" > $2
and "album_asset"."updateId" <= $3
and (
"album"."ownerId" = $4
or "album_user"."usersId" = $5
)
order by
"asset"."updateId" asc
-- SyncRepository.albumAsset.getCreates
select
"album_asset"."updateId",
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."libraryId"
from
"album_asset" as "album_asset"
inner join "asset" on "asset"."id" = "album_asset"."assetsId"
inner join "album" on "album"."id" = "album_asset"."albumsId"
left join "album_user" on "album_user"."albumsId" = "album_asset"."albumsId"
where
"album_asset"."updateId" < $1
and "album_asset"."updateId" > $2
and (
"album"."ownerId" = $3
or "album_user"."usersId" = $4
)
order by
"album_asset"."updateId" asc
-- SyncRepository.albumAssetExif.getBackfill
select
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"album_asset"."updateId"
from
"album_asset" as "album_asset"
inner join "asset_exif" on "asset_exif"."assetId" = "album_asset"."assetsId"
where
"album_asset"."updateId" < $1
and "album_asset"."updateId" <= $2
and "album_asset"."updateId" >= $3
and "album_asset"."albumsId" = $4
order by
"album_asset"."updateId" asc
-- SyncRepository.albumAssetExif.getUpdates
select
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"asset_exif"."updateId"
from
"asset_exif" as "asset_exif"
inner join "album_asset" on "album_asset"."assetsId" = "asset_exif"."assetId"
inner join "album" on "album"."id" = "album_asset"."albumsId"
left join "album_user" on "album_user"."albumsId" = "album_asset"."albumsId"
where
"asset_exif"."updateId" < $1
and "asset_exif"."updateId" > $2
and "album_asset"."updateId" <= $3
and (
"album"."ownerId" = $4
or "album_user"."usersId" = $5
)
order by
"asset_exif"."updateId" asc
-- SyncRepository.albumAssetExif.getCreates
select
"album_asset"."updateId",
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps"
from
"album_asset" as "album_asset"
inner join "asset_exif" on "asset_exif"."assetId" = "album_asset"."assetsId"
inner join "album" on "album"."id" = "album_asset"."albumsId"
left join "album_user" on "album_user"."albumsId" = "album_asset"."albumsId"
where
"album_asset"."updateId" < $1
and "album_asset"."updateId" > $2
and (
"album"."ownerId" = $3
or "album_user"."usersId" = $4
)
order by
"album_asset"."updateId" asc
-- SyncRepository.albumToAsset.getBackfill
select
"album_asset"."assetsId" as "assetId",
"album_asset"."albumsId" as "albumId",
"album_asset"."updateId"
from
"album_asset" as "album_asset"
where
"album_asset"."updateId" < $1
and "album_asset"."updateId" <= $2
and "album_asset"."updateId" >= $3
and "album_asset"."albumsId" = $4
order by
"album_asset"."updateId" asc
-- SyncRepository.albumToAsset.getDeletes
select
"id",
"assetId",
"albumId"
from
"album_asset_audit" as "album_asset_audit"
where
"album_asset_audit"."id" < $1
and "album_asset_audit"."id" > $2
and "albumId" in (
select
"id"
from
"album"
where
"ownerId" = $3
union
(
select
"album_user"."albumsId" as "id"
from
"album_user"
where
"album_user"."usersId" = $4
)
)
order by
"album_asset_audit"."id" asc
-- SyncRepository.albumToAsset.getUpserts
select
"album_asset"."assetsId" as "assetId",
"album_asset"."albumsId" as "albumId",
"album_asset"."updateId"
from
"album_asset" as "album_asset"
inner join "album" on "album"."id" = "album_asset"."albumsId"
left join "album_user" on "album_user"."albumsId" = "album_asset"."albumsId"
where
"album_asset"."updateId" < $1
and "album_asset"."updateId" > $2
and (
"album"."ownerId" = $3
or "album_user"."usersId" = $4
)
order by
"album_asset"."updateId" asc
-- SyncRepository.albumUser.getBackfill
select
"album_user"."albumsId" as "albumId",
"album_user"."usersId" as "userId",
"album_user"."role",
"album_user"."updateId"
from
"album_user" as "album_user"
where
"album_user"."updateId" < $1
and "album_user"."updateId" <= $2
and "album_user"."updateId" >= $3
and "albumsId" = $4
order by
"album_user"."updateId" asc
-- SyncRepository.albumUser.getDeletes
select
"id",
"userId",
"albumId"
from
"album_user_audit" as "album_user_audit"
where
"album_user_audit"."id" < $1
and "album_user_audit"."id" > $2
and "albumId" in (
select
"id"
from
"album"
where
"ownerId" = $3
union
(
select
"album_user"."albumsId" as "id"
from
"album_user"
where
"album_user"."usersId" = $4
)
)
order by
"album_user_audit"."id" asc
-- SyncRepository.albumUser.getUpserts
select
"album_user"."albumsId" as "albumId",
"album_user"."usersId" as "userId",
"album_user"."role",
"album_user"."updateId"
from
"album_user" as "album_user"
where
"album_user"."updateId" < $1
and "album_user"."updateId" > $2
and "album_user"."albumsId" in (
select
"id"
from
"album"
where
"ownerId" = $3
union
(
select
"albumUsers"."albumsId" as "id"
from
"album_user" as "albumUsers"
where
"albumUsers"."usersId" = $4
)
)
order by
"album_user"."updateId" asc
-- SyncRepository.asset.getDeletes
select
"id",
"assetId"
from
"asset_audit" as "asset_audit"
where
"asset_audit"."id" < $1
and "asset_audit"."id" > $2
and "ownerId" = $3
order by
"asset_audit"."id" asc
-- SyncRepository.asset.getUpserts
select
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."libraryId",
"asset"."updateId"
from
"asset" as "asset"
where
"asset"."updateId" < $1
and "asset"."updateId" > $2
and "ownerId" = $3
order by
"asset"."updateId" asc
-- SyncRepository.assetExif.getUpserts
select
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"asset_exif"."updateId"
from
"asset_exif" as "asset_exif"
where
"asset_exif"."updateId" < $1
and "asset_exif"."updateId" > $2
and "assetId" in (
select
"id"
from
"asset"
where
"ownerId" = $3
)
order by
"asset_exif"."updateId" asc
-- SyncRepository.assetFace.getDeletes
select
"asset_face_audit"."id",
"assetFaceId"
from
"asset_face_audit" as "asset_face_audit"
left join "asset" on "asset"."id" = "asset_face_audit"."assetId"
where
"asset_face_audit"."id" < $1
and "asset_face_audit"."id" > $2
and "asset"."ownerId" = $3
order by
"asset_face_audit"."id" asc
-- SyncRepository.assetFace.getUpserts
select
"asset_face"."id",
"assetId",
"personId",
"imageWidth",
"imageHeight",
"boundingBoxX1",
"boundingBoxY1",
"boundingBoxX2",
"boundingBoxY2",
"sourceType",
"asset_face"."updateId"
from
"asset_face" as "asset_face"
left join "asset" on "asset"."id" = "asset_face"."assetId"
where
"asset_face"."updateId" < $1
and "asset_face"."updateId" > $2
and "asset"."ownerId" = $3
order by
"asset_face"."updateId" asc
-- SyncRepository.authUser.getUpserts
select
"id",
"name",
"email",
"avatarColor",
"deletedAt",
"updateId",
"profileImagePath",
"profileChangedAt",
"isAdmin",
"pinCode",
"oauthId",
"storageLabel",
"quotaSizeInBytes",
"quotaUsageInBytes"
from
"user" as "user"
where
"user"."updateId" < $1
and "user"."updateId" > $2
order by
"user"."updateId" asc
-- SyncRepository.memory.getDeletes
select
"id",
"memoryId"
from
"memory_audit" as "memory_audit"
where
"memory_audit"."id" < $1
and "memory_audit"."id" > $2
and "userId" = $3
order by
"memory_audit"."id" asc
-- SyncRepository.memory.getUpserts
select
"id",
"createdAt",
"updatedAt",
"deletedAt",
"ownerId",
"type",
"data",
"isSaved",
"memoryAt",
"seenAt",
"showAt",
"hideAt",
"updateId"
from
"memory" as "memory"
where
"memory"."updateId" < $1
and "memory"."updateId" > $2
and "ownerId" = $3
order by
"memory"."updateId" asc
-- SyncRepository.memoryToAsset.getDeletes
select
"id",
"memoryId",
"assetId"
from
"memory_asset_audit" as "memory_asset_audit"
where
"memory_asset_audit"."id" < $1
and "memory_asset_audit"."id" > $2
and "memoryId" in (
select
"id"
from
"memory"
where
"ownerId" = $3
)
order by
"memory_asset_audit"."id" asc
-- SyncRepository.memoryToAsset.getUpserts
select
"memoriesId" as "memoryId",
"assetsId" as "assetId",
"updateId"
from
"memory_asset" as "memory_asset"
where
"memory_asset"."updateId" < $1
and "memory_asset"."updateId" > $2
and "memoriesId" in (
select
"id"
from
"memory"
where
"ownerId" = $3
)
order by
"memory_asset"."updateId" asc
-- SyncRepository.partner.getCreatedAfter
select
"sharedById",
"createId"
from
"partner"
where
"sharedWithId" = $1
and "createId" >= $2
and "createId" < $3
order by
"partner"."createId" asc
-- SyncRepository.partner.getDeletes
select
"id",
"sharedById",
"sharedWithId"
from
"partner_audit" as "partner_audit"
where
"partner_audit"."id" < $1
and "partner_audit"."id" > $2
and (
"sharedById" = $3
or "sharedWithId" = $4
)
order by
"partner_audit"."id" asc
-- SyncRepository.partner.getUpserts
select
"sharedById",
"sharedWithId",
"inTimeline",
"updateId"
from
"partner" as "partner"
where
"partner"."updateId" < $1
and "partner"."updateId" > $2
and (
"sharedById" = $3
or "sharedWithId" = $4
)
order by
"partner"."updateId" asc
-- SyncRepository.partnerAsset.getBackfill
select
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."libraryId",
"asset"."updateId"
from
"asset" as "asset"
where
"asset"."updateId" < $1
and "asset"."updateId" <= $2
and "asset"."updateId" >= $3
and "ownerId" = $4
order by
"asset"."updateId" asc
-- SyncRepository.partnerAsset.getDeletes
select
"id",
"assetId"
from
"asset_audit" as "asset_audit"
where
"asset_audit"."id" < $1
and "asset_audit"."id" > $2
and "ownerId" in (
select
"sharedById"
from
"partner"
where
"sharedWithId" = $3
)
order by
"asset_audit"."id" asc
-- SyncRepository.partnerAsset.getUpserts
select
"asset"."id",
"asset"."ownerId",
"asset"."originalFileName",
"asset"."thumbhash",
"asset"."checksum",
"asset"."fileCreatedAt",
"asset"."fileModifiedAt",
"asset"."localDateTime",
"asset"."type",
"asset"."deletedAt",
"asset"."isFavorite",
"asset"."visibility",
"asset"."duration",
"asset"."livePhotoVideoId",
"asset"."stackId",
"asset"."libraryId",
"asset"."updateId"
from
"asset" as "asset"
where
"asset"."updateId" < $1
and "asset"."updateId" > $2
and "ownerId" in (
select
"sharedById"
from
"partner"
where
"sharedWithId" = $3
)
order by
"asset"."updateId" asc
-- SyncRepository.partnerAssetExif.getBackfill
select
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"asset_exif"."updateId"
from
"asset_exif" as "asset_exif"
inner join "asset" on "asset"."id" = "asset_exif"."assetId"
where
"asset_exif"."updateId" < $1
and "asset_exif"."updateId" <= $2
and "asset_exif"."updateId" >= $3
and "asset"."ownerId" = $4
order by
"asset_exif"."updateId" asc
-- SyncRepository.partnerAssetExif.getUpserts
select
"asset_exif"."assetId",
"asset_exif"."description",
"asset_exif"."exifImageWidth",
"asset_exif"."exifImageHeight",
"asset_exif"."fileSizeInByte",
"asset_exif"."orientation",
"asset_exif"."dateTimeOriginal",
"asset_exif"."modifyDate",
"asset_exif"."timeZone",
"asset_exif"."latitude",
"asset_exif"."longitude",
"asset_exif"."projectionType",
"asset_exif"."city",
"asset_exif"."state",
"asset_exif"."country",
"asset_exif"."make",
"asset_exif"."model",
"asset_exif"."lensModel",
"asset_exif"."fNumber",
"asset_exif"."focalLength",
"asset_exif"."iso",
"asset_exif"."exposureTime",
"asset_exif"."profileDescription",
"asset_exif"."rating",
"asset_exif"."fps",
"asset_exif"."updateId"
from
"asset_exif" as "asset_exif"
where
"asset_exif"."updateId" < $1
and "asset_exif"."updateId" > $2
and "assetId" in (
select
"id"
from
"asset"
where
"ownerId" in (
select
"sharedById"
from
"partner"
where
"sharedWithId" = $3
)
)
order by
"asset_exif"."updateId" asc
-- SyncRepository.partnerStack.getDeletes
select
"id",
"stackId"
from
"stack_audit" as "stack_audit"
where
"stack_audit"."id" < $1
and "stack_audit"."id" > $2
and "userId" in (
select
"sharedById"
from
"partner"
where
"sharedWithId" = $3
)
order by
"stack_audit"."id" asc
-- SyncRepository.partnerStack.getBackfill
select
"stack"."id",
"stack"."createdAt",
"stack"."updatedAt",
"stack"."primaryAssetId",
"stack"."ownerId",
"updateId"
from
"stack" as "stack"
where
"stack"."updateId" < $1
and "stack"."updateId" <= $2
and "stack"."updateId" >= $3
and "ownerId" = $4
order by
"stack"."updateId" asc
-- SyncRepository.partnerStack.getUpserts
select
"stack"."id",
"stack"."createdAt",
"stack"."updatedAt",
"stack"."primaryAssetId",
"stack"."ownerId",
"updateId"
from
"stack" as "stack"
where
"stack"."updateId" < $1
and "stack"."updateId" > $2
and "ownerId" in (
select
"sharedById"
from
"partner"
where
"sharedWithId" = $3
)
order by
"stack"."updateId" asc
-- SyncRepository.people.getDeletes
select
"id",
"personId"
from
"person_audit" as "person_audit"
where
"person_audit"."id" < $1
and "person_audit"."id" > $2
and "ownerId" = $3
order by
"person_audit"."id" asc
-- SyncRepository.people.getUpserts
select
"id",
"createdAt",
"updatedAt",
"ownerId",
"name",
"birthDate",
"isHidden",
"isFavorite",
"color",
"updateId",
"faceAssetId"
from
"person" as "person"
where
"person"."updateId" < $1
and "person"."updateId" > $2
and "ownerId" = $3
order by
"person"."updateId" asc
-- SyncRepository.stack.getDeletes
select
"id",
"stackId"
from
"stack_audit" as "stack_audit"
where
"stack_audit"."id" < $1
and "stack_audit"."id" > $2
and "userId" = $3
order by
"stack_audit"."id" asc
-- SyncRepository.stack.getUpserts
select
"stack"."id",
"stack"."createdAt",
"stack"."updatedAt",
"stack"."primaryAssetId",
"stack"."ownerId",
"updateId"
from
"stack" as "stack"
where
"stack"."updateId" < $1
and "stack"."updateId" > $2
and "ownerId" = $3
order by
"stack"."updateId" asc
-- SyncRepository.user.getDeletes
select
"id",
"userId"
from
"user_audit" as "user_audit"
where
"user_audit"."id" < $1
and "user_audit"."id" > $2
order by
"user_audit"."id" asc
-- SyncRepository.user.getUpserts
select
"id",
"name",
"email",
"avatarColor",
"deletedAt",
"updateId",
"profileImagePath",
"profileChangedAt"
from
"user" as "user"
where
"user"."updateId" < $1
and "user"."updateId" > $2
order by
"user"."updateId" asc
-- SyncRepository.userMetadata.getDeletes
select
"id",
"userId",
"key"
from
"user_metadata_audit" as "user_metadata_audit"
where
"user_metadata_audit"."id" < $1
and "user_metadata_audit"."id" > $2
and "userId" = $3
order by
"user_metadata_audit"."id" asc
-- SyncRepository.userMetadata.getUpserts
select
"userId",
"key",
"value",
"updateId"
from
"user_metadata" as "user_metadata"
where
"user_metadata"."updateId" < $1
and "user_metadata"."updateId" > $2
and "userId" = $3
order by
"user_metadata"."updateId" asc