Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
feat: added totaltests column in the api
Browse files Browse the repository at this point in the history
  • Loading branch information
vycdev committed Jul 12, 2020
1 parent 875c928 commit c237a62
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Knex from "knex";

export const up = async (knex: Knex) => {
return knex.schema.table("users", table => {
table
.integer("totaltests")
.notNullable()
.defaultTo(0);
});
};

export const down = async (knex: Knex) => {
return knex.schema.table("users", table => {
return table.dropColumn("totaltests");
});
};
18 changes: 14 additions & 4 deletions packages/api/db/seeds/examples/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ interface Users {
description?: string | null;
exp: number;
tutorials: number[];
country: string;
totaltests: number;
}

export default [
Expand All @@ -16,7 +18,9 @@ export default [
role: "admin",
description: null,
exp: 8,
tutorials: []
tutorials: [],
country: "RO",
totaltests: 0
},
{
name: "MKGUN3",
Expand All @@ -25,7 +29,9 @@ export default [
role: "member",
description: null,
exp: 4,
tutorials: []
tutorials: [],
country: "USA",
totaltests: 5
},
{
name: "NotAUser",
Expand All @@ -34,7 +40,9 @@ export default [
role: "member",
description: null,
exp: 2,
tutorials: []
tutorials: [],
country: "LY",
totaltests: 100
},
{
name: "Guy2",
Expand All @@ -43,6 +51,8 @@ export default [
role: "member",
description: "But hey, I have a description!",
exp: 0,
tutorials: []
tutorials: [],
country: "FR",
totaltests: 20
}
] as readonly Users[];
3 changes: 2 additions & 1 deletion packages/api/src/modules/users/actions/createUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const createUser = async (
role: "member",
password: encryptedPassword,
exp: 0,
tutorials: []
tutorials: [],
totaltests: 0
},
"*"
)
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/modules/users/types/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export default interface User {
description?: string | null;
tutorials: number[];
country: string;
totaltests: number;
}

0 comments on commit c237a62

Please sign in to comment.