forked from sequelize/sequelize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sscce.ts
40 lines (32 loc) · 879 Bytes
/
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
38
39
40
import { DataTypes, Model } from '@sequelize/core';
import { Attribute } from '@sequelize/core/decorators-legacy';
import { SqliteDialect } from '@sequelize/sqlite3';
import { expect } from 'chai';
import { createSequelizeInstance } from './dev/sscce-helpers';
class User extends Model {
@Attribute({
type: DataTypes.STRING,
allowNull: false,
})
declare username: string;
@Attribute({
type: DataTypes.DATE,
allowNull: false,
})
declare birthday: Date;
}
const sequelize = createSequelizeInstance({
dialect: SqliteDialect,
benchmark: true,
models: [User],
});
(async () => {
await sequelize.sync({ force: true });
const jane = await User.create({
username: 'janedoe',
birthday: new Date(1980, 6, 20),
});
console.log('\nJane:', jane.toJSON());
await sequelize.close();
expect(jane.username).to.equal('janedoe');
})();