Compare commits

..

6 Commits

Author SHA1 Message Date
standardci
ae56126585 chore(release): publish new version
- @standardnotes/syncing-server@1.26.10
2022-12-15 14:41:40 +00:00
Karol Sójko
6dcf0ac124 fix(syncing-server): item query created_at condition 2022-12-15 15:38:56 +01:00
standardci
63e2ce43c2 chore(release): publish new version
- @standardnotes/syncing-server@1.26.9
2022-12-15 13:40:30 +00:00
Karol Sójko
f27aa21eb5 fix(syncing-server): fetching items in raw mode 2022-12-15 14:38:32 +01:00
standardci
42926c663b chore(release): publish new version
- @standardnotes/syncing-server@1.26.8
2022-12-15 11:37:14 +00:00
Karol Sójko
d38116183c fix(syncing-server): select fields in query 2022-12-15 12:35:26 +01:00
6 changed files with 31 additions and 8 deletions

View File

@@ -3,6 +3,24 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.26.10](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.9...@standardnotes/syncing-server@1.26.10) (2022-12-15)
### Bug Fixes
* **syncing-server:** item query created_at condition ([6dcf0ac](https://github.com/standardnotes/syncing-server-js/commit/6dcf0ac124252c441d08a67f2954441ab6266bdf))
## [1.26.9](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.8...@standardnotes/syncing-server@1.26.9) (2022-12-15)
### Bug Fixes
* **syncing-server:** fetching items in raw mode ([f27aa21](https://github.com/standardnotes/syncing-server-js/commit/f27aa21eb52a73b748e3a555bf201c834fd34aad))
## [1.26.8](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.7...@standardnotes/syncing-server@1.26.8) (2022-12-15)
### Bug Fixes
* **syncing-server:** select fields in query ([d381161](https://github.com/standardnotes/syncing-server-js/commit/d38116183c9f7b6fb6d13d9076571fef72be555c))
## [1.26.7](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.6...@standardnotes/syncing-server@1.26.7) (2022-12-15)
**Note:** Version bump only for package @standardnotes/syncing-server

View File

@@ -28,7 +28,7 @@ const fixRevisionsOwnership = async (
const itemsCount = await itemRepository.countAll({
createdBetween: [createdAfter, createdBefore],
selectFields: ['uuid', 'user_uuid'],
selectString: 'item.uuid as uuid, item.user_uuid as userUuid',
contentType: [ContentType.Note, ContentType.File],
sortOrder: 'ASC',
sortBy: 'uuid',
@@ -52,9 +52,9 @@ const fixRevisionsOwnership = async (
)
}
const items = await itemRepository.findAll({
const items = await itemRepository.findAllRaw<{ uuid: string; userUuid: string }>({
createdBetween: [createdAfter, createdBefore],
selectFields: ['uuid', 'user_uuid'],
selectString: 'item.uuid as uuid, item.user_uuid as userUuid',
contentType: [ContentType.Note, ContentType.File],
offset: (page - 1) * revisionsProcessingLimit,
limit: revisionsProcessingLimit,

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.26.7",
"version": "1.26.10",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -10,5 +10,5 @@ export type ItemQuery = {
offset?: number
limit?: number
createdBetween?: Date[]
selectFields?: string[]
selectString?: string
}

View File

@@ -6,6 +6,7 @@ import { ExtendedIntegrityPayload } from './ExtendedIntegrityPayload'
export interface ItemRepositoryInterface {
deleteByUserUuid(userUuid: string): Promise<void>
findAll(query: ItemQuery): Promise<Item[]>
findAllRaw<T>(query: ItemQuery): Promise<T[]>
streamAll(query: ItemQuery): Promise<ReadStream>
countAll(query: ItemQuery): Promise<number>
findContentSizeForComputingTransferLimit(

View File

@@ -103,6 +103,10 @@ export class MySQLItemRepository implements ItemRepositoryInterface {
return this.createFindAllQueryBuilder(query).getMany()
}
async findAllRaw<T>(query: ItemQuery): Promise<T[]> {
return this.createFindAllQueryBuilder(query).getRawMany<T>()
}
async streamAll(query: ItemQuery): Promise<ReadStream> {
return this.createFindAllQueryBuilder(query).stream()
}
@@ -135,8 +139,8 @@ export class MySQLItemRepository implements ItemRepositoryInterface {
queryBuilder.orderBy(`item.${query.sortBy}`, query.sortOrder)
}
if (query.selectFields !== undefined) {
queryBuilder.select(query.selectFields)
if (query.selectString !== undefined) {
queryBuilder.select(query.selectString)
}
if (query.userUuid !== undefined) {
queryBuilder.where('item.user_uuid = :userUuid', { userUuid: query.userUuid })
@@ -160,7 +164,7 @@ export class MySQLItemRepository implements ItemRepositoryInterface {
})
}
if (query.createdBetween !== undefined) {
queryBuilder.andWhere('item.created_at BETWEEN :createdAfter AND :createdBefore', {
queryBuilder.andWhere('item.created_at >= :createdAfter AND item.created_at <= :createdBefore', {
createdAfter: query.createdBetween[0].toISOString(),
createdBefore: query.createdBetween[1].toISOString(),
})