-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from wappla/feature/improve-for-joined-tables
Added typescript, replaced babel by swc and added support for column alias
- Loading branch information
Showing
19 changed files
with
5,767 additions
and
4,591 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ cat >dist/esm/package.json <<!EOF | |
{ | ||
"type": "module" | ||
} | ||
!EOF | ||
!EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
coverageDirectory: 'coverage', | ||
globalSetup: './src/testingSetup.js', | ||
globalSetup: './src/testingSetup.ts', | ||
transform: { | ||
'^.+\\.(t|j)sx?$': '@swc/jest', | ||
}, | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Knex } from 'knex' | ||
import { | ||
createTestDatabase, | ||
destroyTestDatabase, | ||
} from './testing' | ||
import UserFactory, { TABLE_USERS } from 'factories/UserFactory' | ||
|
||
const TOTAL_USERS = 2000 | ||
|
||
export const createBenchmarkDatabase = async (databaseName: string) => { | ||
const knex = await createTestDatabase(databaseName) | ||
if (knex) { | ||
const now = knex.fn.now() | ||
await knex.schema.createTable(TABLE_USERS, (table) => { | ||
table.increments().primary() | ||
table.datetime('createdAt').defaultTo(now) | ||
table.datetime('updatedAt').defaultTo(now) | ||
table.string('email').notNullable() | ||
table.string('firstName') | ||
table.string('lastName') | ||
table.unique(['email']) | ||
}) | ||
await UserFactory.create(TOTAL_USERS) | ||
} | ||
} | ||
|
||
export const destroyBenchmarkDatabase = async (knex: Knex) => { | ||
await destroyTestDatabase(knex) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import faker from '@faker-js/faker' | ||
import { KnexFactory, getKnexConnection } from '../testing' | ||
|
||
export const TABLE_TASKS = 'tasks' | ||
|
||
export const TASK_STATUS_PENDING = 'pending' | ||
export const TASK_STATUS_COMPLETED = 'completed' | ||
|
||
export const tasks = (databaseName?: string) => { | ||
const knex = getKnexConnection(databaseName) | ||
return knex(TABLE_TASKS) | ||
} | ||
|
||
export default class TaskFactory extends KnexFactory { | ||
static get table() { | ||
return tasks | ||
} | ||
|
||
static async make() { | ||
return { | ||
name: faker.unique(faker.name.jobTitle), | ||
status: faker.helpers.arrayElement([TASK_STATUS_PENDING, TASK_STATUS_COMPLETED]), | ||
createdAt: faker.date.past(), | ||
} | ||
} | ||
} |
Oops, something went wrong.