add full page width preference

This commit is contained in:
Philipinho
2024-07-03 11:00:42 +01:00
parent d1ae117f76
commit 8f056d1071
10 changed files with 135 additions and 38 deletions

View File

@ -15,6 +15,7 @@ import {
executeWithPagination,
PaginationResult,
} from '@docmost/db/pagination/pagination';
import { sql } from 'kysely';
@Injectable()
export class UserRepo {
@ -157,6 +158,24 @@ export class UserRepo {
return result;
}
async updatePreference(
userId: string,
prefKey: string,
prefValue: string | boolean,
) {
return await this.db
.updateTable('users')
.set({
settings: sql`COALESCE(settings, '{}'::jsonb)
|| jsonb_build_object('preferences', COALESCE(settings->'preferences', '{}'::jsonb)
|| jsonb_build_object('${sql.raw(prefKey)}', ${sql.lit(prefValue)}))`,
updatedAt: new Date(),
})
.where('id', '=', userId)
.returning(this.baseFields)
.executeTakeFirst();
}
/*
async getSpaceIds(
workspaceId: string,