4.0.40 • Published 1 year ago

@ailo/knex-utils v4.0.40

Weekly downloads
333
License
UNLICENSED
Repository
github
Last release
1 year ago

@ailo/knex-utils

Utilities to be used in node.js repos using knex.

Usage

First, add it as a dependency:

yarn add @ailo/knex-utils

Then, depending on what you need:

Knex singleton instance (KnexRef)

See /src/KnexRef/KnexRef.ts.

Add ailorn column type to postgres

// database/migrations/123_create_ailorn_column_type.js
const { V2AilornColumnTypeMigration } = require("@ailo/knex-utils");
module.exports = V2AilornColumnTypeMigration;

Migrating from V1 to V2 ailorn column type to postgres

// database/migrations/123_create_ailorn_column_type.js
const { V1ToV2AilornColumnTypeMigration } = require("@ailo/knex-utils");
module.exports = V1ToV2AilornColumnTypeMigration;

You will also need to change your initial ailorn column migration to import from V1AilornColumnTypeMigration rather than CreateAilornColumnTypeMigration, which has been removed.

Test Utils (e.g. useKnex)

// database/migrations/tests/1002_rename_user_to_person.test.ts
import { useKnex } from "@ailo/knex-utils/build/main/test-utils";
import { testMigrationConfig } from "knexConfig";
import moment from "moment";
import { up } from "../1002_rename_user_to_person";

const knexRef = useKnex({
  knexConfig: testMigrationConfig,
  migrateTo: "1001",
});

it("db migration 1002_rename_user_to_person works", async () => {
  const knex = knexRef.current;

  await knex("user").insert({
    name: "john",
  });
  await up(knex);

  const [user] = await knex("person").select("id", "name");
  expect(user.name).toEqual("john");
});

local-db shell file

yarn local-db
yarn local-db test

History Table DB migration utils

See /src/history-utils/README.md.

Transaction utils

See /src/transactions/README.md.

Development

yarn
yarn start

Testing

yarn lint # prettier and eslint
yarn test # unit tests
yarn test:watch # unit tests in watch mode

Releasing

yarn release
4.0.42-fix-type

1 year ago

4.0.40

1 year ago

4.0.38

1 year ago

4.0.34-ts-4.4.4

1 year ago

4.0.27

1 year ago

4.0.36-ts-4.4.4

1 year ago

4.0.33

1 year ago

4.0.20

2 years ago

4.0.17

2 years ago

4.0.15

2 years ago

4.0.13

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

3.1.0

2 years ago

2.2.5

2 years ago

2.2.4

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.1

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

1.14.1

3 years ago

1.14.0

3 years ago

1.13.0

4 years ago

1.12.1

4 years ago

1.11.2

4 years ago

1.11.0

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.9.5

5 years ago

1.9.3

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.5

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago