forked from sequelize/sequelize-sscce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sscce.ts
37 lines (29 loc) · 1.05 KB
/
sscce.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Require the necessary things from Sequelize
import { Model, DataTypes } from 'sequelize';
// This function should be used instead of `new Sequelize()`.
// It applies the config for your SSCCE to work on CI.
import createSequelizeInstance = require('./utils/create-sequelize-instance');
// This is an utility logger that should be preferred over `console.log()`.
import log = require('./utils/log');
// You can use chai assertions directly in your SSCCE if you want.
import { expect } from 'chai';
// Your SSCCE goes inside this function.
export async function run() {
const sequelize = createSequelizeInstance({
logQueryParameters: true,
benchmark: true,
define: {
timestamps: false // For less clutter in the SSCCE
}
});
class Foo extends Model {};
Foo.init({
name: DataTypes.TEXT
}, {
sequelize,
modelName: 'Foo'
});
await sequelize.sync();
log(await Foo.create({ name: 'TS foo' }));
expect(await Foo.count()).to.equal(1);
}