* use lower case db column names
* fix signup workspaceId
This commit is contained in:
Philipinho
2024-03-29 16:25:42 +00:00
parent 82da4ffdc2
commit b241523ff6
25 changed files with 248 additions and 407 deletions

View File

@ -39,7 +39,13 @@ export class SignupService {
this.db,
async (trx) => {
// create user
const user = await this.userRepo.insertUser(createUserDto, trx);
const user = await this.userRepo.insertUser(
{
...createUserDto,
workspaceId: workspaceId,
},
trx,
);
// add user to workspace
await this.workspaceService.addUserToWorkspace(
@ -88,7 +94,13 @@ export class SignupService {
async (trx) => {
// create user
const user = await this.userRepo.insertUser(createAdminUserDto, trx);
await this.createWorkspace(user, createAdminUserDto.workspaceName, trx);
const workspace = await this.createWorkspace(
user,
createAdminUserDto.workspaceName,
trx,
);
user.workspaceId = workspace.id;
return user;
},
trx,

View File

@ -64,7 +64,7 @@ export async function removeFromArrayAndSave(
if (index > -1) {
array.splice(index, 1);
await trx
.updateTable('page_ordering')
.updateTable('pageOrdering')
.set(entity)
.where('id', '=', entity.id)
.execute();

View File

@ -62,7 +62,7 @@ export class PageOrderingService {
// it should save or update right?
// await manager.save(spaceOrdering); //TODO: to update or create new record? pretty confusing
await trx
.updateTable('page_ordering')
.updateTable('pageOrdering')
.set(spaceOrdering)
.where('id', '=', spaceOrdering.id)
.execute();
@ -109,7 +109,7 @@ export class PageOrderingService {
// Modify the children list of the new parentPage and save
orderPageList(parentPageOrdering.childrenIds, dto);
await trx
.updateTable('page_ordering')
.updateTable('pageOrdering')
.set(parentPageOrdering)
.where('id', '=', parentPageOrdering.id)
.execute();
@ -238,7 +238,7 @@ export class PageOrderingService {
if (!ordering.childrenIds.includes(childId)) {
ordering.childrenIds.unshift(childId);
await trx
.updateTable('page_ordering')
.updateTable('pageOrdering')
.set(ordering)
.where('id', '=', ordering.id)
.execute();
@ -252,7 +252,7 @@ export class PageOrderingService {
trx: KyselyTransaction,
): Promise<PageOrdering> {
return trx
.selectFrom('page_ordering')
.selectFrom('pageOrdering')
.selectAll()
.where('entityId', '=', entityId)
.where('entityType', '=', entityType)
@ -267,7 +267,7 @@ export class PageOrderingService {
trx: KyselyTransaction,
): Promise<PageOrdering> {
await trx
.insertInto('page_ordering')
.insertInto('pageOrdering')
.values({
entityId,
entityType,
@ -285,7 +285,7 @@ export class PageOrderingService {
spaceId: string,
): Promise<{ id: string; childrenIds: string[]; spaceId: string }> {
return await this.db
.selectFrom('page_ordering')
.selectFrom('pageOrdering')
.select(['id', 'childrenIds', 'spaceId'])
.where('entityId', '=', spaceId)
.where('entityType', '=', OrderingEntity.SPACE)

View File

@ -56,7 +56,6 @@ export class WorkspaceService {
name: createWorkspaceDto.name,
hostname: createWorkspaceDto.hostname,
description: createWorkspaceDto.description,
creatorId: user.id,
},
trx,
);
@ -77,9 +76,10 @@ export class WorkspaceService {
})
.execute();
// add user to default group
await this.groupUserService.addUserToDefaultGroup(
// add user to default group created above
await this.groupUserService.addUserToGroup(
user.id,
group.id,
workspace.id,
trx,
);