Skip to content

TypeORM 0.3 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '10', '12', '14', '16' ]
node: ["14", "16"]
name: Node ${{ matrix.node }} sample
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
cache: 'npm'
cache: "npm"
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm test
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
cache: 'npm'
cache: "npm"
node-version: 14
- run: npm ci
- run: npm run build
- run: npm run build
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 4.2.0

### Breaking Changes

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.

- Minimum Node version increased from 10 to 14
- `extendConnectionOptions` renamed to `extendDataSourceOptions`
- `extendDataSourceOptions` now requires a parameter, as `ormconfig` is now deprecated

## 3.0.0 - BREAKING CHANGES

- Refactoring to facilitate iterative construction of the corpus (multiple `.addData()` instead of a one-time `buildCorpus()`), and export/import of corpus internal data.
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,37 @@ This rewrite was created for the Discord bot [markov-discord](https://github.com

## Prerequisites

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

## Installing

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

## Usage

```typescript
import Markov from 'markov-strings-db';
import ormconfig from './ormconfig';
import { DataSource } from 'typeorm';

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


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

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

// If you have a non-default connection (you probably don't), pass it in here. Otherwise, setup() is called implicitly on any async function.
await markov.setup(connection);
// 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.
await markov.setup(dataSource);

// Add data for the generator
await markov.addData(data)
Expand All @@ -72,7 +75,7 @@ console.log(result)
}
*/

await markov.disconnect();
await markov.destroy();
```

## API
Expand Down
18 changes: 0 additions & 18 deletions ormconfig.js

This file was deleted.

Loading