Skip to content

Commit 8c70352

Browse files
committed
Upgrade to typeorm 0.3
1 parent 8c0a2fa commit 8c70352

File tree

9 files changed

+1341
-1223
lines changed

9 files changed

+1341
-1223
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node: [ '10', '12', '14', '16' ]
14+
node: ["14", "16"]
1515
name: Node ${{ matrix.node }} sample
1616
steps:
1717
- uses: actions/checkout@v2
1818
- name: Setup node
1919
uses: actions/setup-node@v2
2020
with:
21-
cache: 'npm'
21+
cache: "npm"
2222
node-version: ${{ matrix.node }}
2323
- run: npm ci
2424
- run: npm test
@@ -34,7 +34,7 @@ jobs:
3434
- name: Setup node
3535
uses: actions/setup-node@v2
3636
with:
37-
cache: 'npm'
37+
cache: "npm"
3838
node-version: 14
3939
- run: npm ci
40-
- run: npm run build
40+
- run: npm run build

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 4.2.0
4+
5+
### Breaking Changes
6+
7+
typeorm was upgraded to 0.3. See [its changelog](https://github.com/typeorm/typeorm/releases/tag/0.3.0) for its full list of breaking changes.
8+
9+
- Minimum Node version increased from 10 to 14
10+
- `extendConnectionOptions` renamed to `extendDataSourceOptions`
11+
- `extendDataSourceOptions` now requires a parameter, as `ormconfig` is now deprecated
12+
313
## 3.0.0 - BREAKING CHANGES
414

515
- Refactoring to facilitate iterative construction of the corpus (multiple `.addData()` instead of a one-time `buildCorpus()`), and export/import of corpus internal data.

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,37 @@ This rewrite was created for the Discord bot [markov-discord](https://github.com
1818

1919
## Prerequisites
2020

21-
- NodeJS 10+
21+
- NodeJS 14+
2222
- The host app must be configured with a [TypeORM](https://typeorm.io)-compatible database driver
2323

2424
## Installing
2525

2626
- `npm i markov-strings-db`
2727
- Setup a database driver (this project was tested with better-sqlite3)
2828
- Step 4 from [this guide](https://github.com/typeorm/typeorm#installation)
29-
- Setup an [ormconfig file](https://typeorm.io/#/using-ormconfig), or pass in a config object to the `connect()` function
29+
- Setup a [data source config](https://typeorm.io/data-source)
3030

3131
## Usage
3232

3333
```typescript
3434
import Markov from 'markov-strings-db';
35+
import ormconfig from './ormconfig';
36+
import { DataSource } from 'typeorm';
3537

3638
const data = [/* insert a few hundreds/thousands sentences here */];
3739

3840

3941
// Instantiate the Markov generator
4042
const markov = new Markov({ options: { stateSize: 2 }});
4143

42-
// If you have your own database you'd like to combine with Markov's, make sure to extend your connection
43-
const connectionOptions = await Markov.extendConnectionOptions();
44-
// Required: create a connection before using a markov instance. You only need to do this once.
45-
const connection = await createConnection(connectionOptions);
44+
// If you have your own database you'd like to combine with Markov's, make sure to extend your data source options
45+
const dataSourceOptions = await Markov.extendDataSourceOptions(ormconfig);
46+
// Required: create a data source before using a markov instance. You only need to do this once.
47+
const dataSource = new DataSource(dataSourceOptions);
48+
await dataSource.initialize();
4649

47-
// If you have a non-default connection (you probably don't), pass it in here. Otherwise, setup() is called implicitly on any async function.
48-
await markov.setup(connection);
50+
// If you have a non-default data source (you probably don't), pass it in here. Otherwise, setup() is called implicitly on any async function.
51+
await markov.setup(dataSource);
4952

5053
// Add data for the generator
5154
await markov.addData(data)
@@ -72,7 +75,7 @@ console.log(result)
7275
}
7376
*/
7477

75-
await markov.disconnect();
78+
await markov.destroy();
7679
```
7780

7881
## API

ormconfig.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)