mirror of
https://github.com/docmost/docmost.git
synced 2026-09-01 11:26:54 +08:00
feat(bases): allow updateRow to set position atomically
This commit is contained in:
@@ -25,6 +25,11 @@ export class UpdateRowDto {
|
||||
@IsObject()
|
||||
cells: Record<string, unknown>;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
position?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
requestId?: string;
|
||||
|
||||
@@ -135,6 +135,15 @@ export class BaseRowService {
|
||||
const properties = await this.basePropertyRepo.findByPageId(dto.pageId);
|
||||
const validatedCells = this.validateCells(dto.cells, properties);
|
||||
|
||||
// Smoke-check the position (same guard as `reorder`).
|
||||
if (dto.position !== undefined) {
|
||||
try {
|
||||
generateJitteredKeyBetween(dto.position, null);
|
||||
} catch {
|
||||
throw new BadRequestException('Invalid position value');
|
||||
}
|
||||
}
|
||||
|
||||
const existing = await this.baseRowRepo.findById(dto.rowId, { workspaceId });
|
||||
const mergedRow = {
|
||||
...((existing?.cells as Record<string, unknown>) ?? {}),
|
||||
@@ -154,6 +163,7 @@ export class BaseRowService {
|
||||
pageId: dto.pageId,
|
||||
workspaceId,
|
||||
actorId: userId,
|
||||
position: dto.position,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user