mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 22:51:11 +10:00
* fixes and cleanups
* db transactions * add default space to workspace
This commit is contained in:
17
apps/server/src/helpers/db.helper.ts
Normal file
17
apps/server/src/helpers/db.helper.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { DataSource, EntityManager } from 'typeorm';
|
||||
|
||||
export async function transactionWrapper(
|
||||
operation: (...args) => any,
|
||||
datasource: DataSource,
|
||||
entityManager: EntityManager,
|
||||
) {
|
||||
if (entityManager) {
|
||||
return await operation(entityManager);
|
||||
} else {
|
||||
return await datasource.manager.transaction(
|
||||
async (manager: EntityManager) => {
|
||||
return await operation(manager);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,7 @@ export class PaginationOptions {
|
||||
@IsPositive()
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
limit = 25;
|
||||
limit = 20;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ -21,3 +21,8 @@ export class PaginationOptions {
|
||||
return (this.page - 1) * this.limit;
|
||||
}
|
||||
}
|
||||
|
||||
export enum Order {
|
||||
ASC = 'ASC',
|
||||
DESC = 'DESC',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user