Skip to content

Commit 93b3bdb

Browse files
author
hirsch88
committed
house cleaning
1 parent 7f378df commit 93b3bdb

File tree

6 files changed

+17
-15
lines changed

6 files changed

+17
-15
lines changed

src/api/models/User.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ export class User extends Bookshelf.Model<User> {
1818
public get hasTimestamps(): boolean { return true; }
1919

2020
public get Id(): number { return this.get('id'); }
21-
public set Id(value: number) { this.set({ id: value }); };
21+
public set Id(value: number) { this.set({ id: value }); }
2222

2323
public get FirstName(): string { return this.get('firstName'); }
24-
public set FirstName(value: string) { this.set({ id: value }); };
24+
public set FirstName(value: string) { this.set({ id: value }); }
2525

2626
public get LastName(): string { return this.get('lastName'); }
27-
public set LastName(value: string) { this.set({ id: value }); };
27+
public set LastName(value: string) { this.set({ id: value }); }
2828

2929
public get Email(): string { return this.get('email'); }
30-
public set Email(value: string) { this.set({ id: value }); };
30+
public set Email(value: string) { this.set({ id: value }); }
3131

3232
public get UpdatedAt(): Date { return this.get('updatedAt'); }
33-
public set UpdatedAt(value: Date) { this.set({ id: value }); };
33+
public set UpdatedAt(value: Date) { this.set({ id: value }); }
3434

3535
public get CreatedAt(): Date { return this.get('createdAt'); }
36-
public set CreatedAt(value: Date) { this.set({ id: value }); };
36+
public set CreatedAt(value: Date) { this.set({ id: value }); }
3737

3838
public fullName(): string {
3939
return this.FirstName + ' ' + this.LastName;

src/api/repositories/UserRepository.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ export class UserRepository {
6464
public static async update(id: number, data: any): Promise<User> {
6565
const user = User.forge<User>({ id: id });
6666
try {
67-
return await user.save(data, { patch: true });
67+
const updatedUser = await user.save(data, { patch: true });
68+
return await User.fetchById(updatedUser.id);
69+
6870
} catch (error) {
6971
throw new DatabaseException('Could not update the user!', error);
7072
}

src/core/Bookshelf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import * as bookshelf from 'bookshelf';
22
import { Knex } from './Knex';
33

44

5-
export const Bookshelf: bookshelf = bookshelf(Knex);
5+
export const Bookshelf: bookshelf = bookshelf(<any>Knex);
66
Bookshelf.plugin(['bookshelf-camelcase']);

src/core/api/extendExpressResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function bodySuccessful<T>(data: T, options: my.ResponseOptions = {}): an
7171
...links(options.links),
7272
data: data
7373
};
74-
};
74+
}
7575

7676
/**
7777
* This body parse is used for error messages to the client
@@ -82,7 +82,7 @@ export function bodyFailed(message: string, error: any): any {
8282
message: message,
8383
error: error
8484
};
85-
};
85+
}
8686

8787
///////////////////////////////////////////////////////
8888
function message(value?: string): any {

src/database/factories/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Factory } from '../../core/database';
2-
import * as models from '../../api/models';
2+
import { User } from '../../api/models/User';
33

44
/**
55
* FACTORIES
@@ -12,7 +12,7 @@ const factory = Factory.getInstance();
1212
/**
1313
* USER - Factory
1414
*/
15-
factory.define(models.User, (faker: Faker.FakerStatic) => {
15+
factory.define(User, (faker: Faker.FakerStatic) => {
1616
const gender = faker.random.number(1);
1717
const fn = faker.name.firstName(gender);
1818
const ln = faker.name.lastName(gender);
@@ -24,4 +24,4 @@ factory.define(models.User, (faker: Faker.FakerStatic) => {
2424
});
2525

2626

27-
export * from '../../core/database/Factory'
27+
export * from '../../core/database/Factory';

src/database/seeds/create_users.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as Knex from 'knex';
22

3-
import * as models from '../../api/models';
3+
import { User } from '../../api/models/User';
44
import { Factory } from '../factories';
55

66

77
exports.seed = async (db: Knex) => {
88
const factory = Factory.getInstance();
9-
await factory.get(models.User)
9+
await factory.get(User)
1010
.create(10);
1111
};

0 commit comments

Comments
 (0)