diff --git a/README.md b/README.md index 22e6adef..61360bd0 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ With `sequelize-typescript@1` comes a repository mode. See [docs](#repository-mo import {Table, Column, Model, HasMany} from 'sequelize-typescript'; @Table -class Person extends Model { +class Person extends Model { @Column name: string; @@ -128,7 +128,7 @@ from sequelize are valid): timestamps: true, ... }) -class Person extends Model {} +class Person extends Model {} ``` #### Table API @@ -223,7 +223,7 @@ Design type | Sequelize data type Get/set accessors do work as well ```typescript @Table -class Person extends Model { +class Person extends Model { @Column get name(): string { @@ -277,7 +277,7 @@ sequelize.addModels([__dirname + '/**/*.model.ts']); A model is matched to a file by its filename. E.g. ```typescript // File User.ts matches the following exported model. -export class User extends Model {} +export class User extends Model {} ``` This is done by comparison of the filename against all exported members. The matching can be customized by specifying the `modelMatch` function in the @@ -308,7 +308,7 @@ export const UserN = 'Not a model'; export const NUser = 'Not a model'; @Table -export class User extends Model { +export class User extends Model { @Column nickname: string; @@ -325,7 +325,7 @@ user.model User -> true (User will be added as model) Another way to match model to file is to make your model the default export. ```TypeScript -export default class User extends Model {} +export default class User extends Model {} ``` > ⚠️ When using paths to add models, keep in mind that they will be loaded during runtime. This means that the path @@ -374,7 +374,7 @@ and `@ForeignKey` annotations. ### One-to-many ```typescript @Table -class Player extends Model { +class Player extends Model { @Column name: string; @@ -391,7 +391,7 @@ class Player extends Model { } @Table -class Team extends Model { +class Team extends Model { @Column name: string; @@ -415,20 +415,20 @@ the players will also be resolved (when passing `include: Player` to the find op ### Many-to-many ```typescript @Table -class Book extends Model { +class Book extends Model { @BelongsToMany(() => Author, () => BookAuthor) authors: Author[]; } @Table -class Author extends Model { +class Author extends Model { @BelongsToMany(() => Book, () => BookAuthor) books: Book[]; } @Table -class BookAuthor extends Model { +class BookAuthor extends Model { @ForeignKey(() => Book) @Column @@ -478,7 +478,7 @@ Note that when using AssociationOptions, certain properties will be overwritten So if you define a model with multiple relations like ```typescript @Table -class Book extends Model { +class Book extends Model { @ForeignKey(() => Person) @Column @@ -496,7 +496,7 @@ class Book extends Model { } @Table -class Person extends Model { +class Person extends Model { @HasMany(() => Book) writtenBooks: Book[]; @@ -533,14 +533,14 @@ But TypeScript wont recognize them and will complain if you try to access `getMo functions. ```typescript @Table -class ModelA extends Model { +class ModelA extends Model { @HasMany(() => ModelB) bs: ModelB[]; } @Table -class ModelB extends Model { +class ModelB extends Model { @BelongsTo(() => ModelA) a: ModelA; @@ -565,7 +565,7 @@ modelA.$create('bs', /* value */ ).then( /* ... */); The `@Index` annotation can be used without passing any parameters. ```typescript @Table -class Person extends Model { +class Person extends Model { @Index // Define an index with default name @Column name: string; @@ -580,7 +580,7 @@ To specify index and index field options, use an object literal (see [indexes define option](https://sequelize.org/v5/manual/models-definition.html#indexes)): ```typescript @Table -class Person extends Model { +class Person extends Model { @Index('my-index') // Define a multi-field index on name and birthday @Column name: string; @@ -639,7 +639,7 @@ const JobIndex = createIndexDecorator({ }); @Table -class Person extends Model { +class Person extends Model { @SomeIndex // Add name to SomeIndex @Column name: string; @@ -707,7 +707,7 @@ Nested scopes and includes in general won't work when using `@Scope` annotation } })) @Table -class User extends Model {} +class User extends Model {} ``` > ⚠️ This will change in the future: Simple includes will be implemented. @@ -733,7 +733,7 @@ Validator | Annotation const HEX_REGEX = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/; @Table -export class Shoe extends Model { +export class Shoe extends Model { @IsUUID(4) @PrimaryKey @@ -801,7 +801,7 @@ sequelize (See sequelize [docs](https://docs.sequelizejs.com/manual/tutorial/sco } })) @Table -export class ShoeWithScopes extends Model { +export class ShoeWithScopes extends Model { @Column readonly secretKey: string; @@ -833,7 +833,7 @@ The name of the method cannot be the same as the name of the hook (for example, ```typescript @Table -export class Person extends Model { +export class Person extends Model { @Column name: string; diff --git a/examples/repository-mode/lib/posts/Post.ts b/examples/repository-mode/lib/posts/Post.ts index 444f5532..714c17f2 100644 --- a/examples/repository-mode/lib/posts/Post.ts +++ b/examples/repository-mode/lib/posts/Post.ts @@ -3,7 +3,7 @@ import {Model, Table, Column, ForeignKey, BelongsTo} from 'sequelize-typescript' import {User} from '../users/User'; @Table -export class Post extends Model { +export class Post extends Model { @Column text!: string; @ForeignKey(() => User) @Column userId!: number; diff --git a/examples/repository-mode/lib/users/User.ts b/examples/repository-mode/lib/users/User.ts index 301dc8df..5b3d0f78 100644 --- a/examples/repository-mode/lib/users/User.ts +++ b/examples/repository-mode/lib/users/User.ts @@ -3,7 +3,7 @@ import {Model, Table, Column, HasMany} from 'sequelize-typescript'; import {Post} from '../posts/Post'; @Table -export class User extends Model { +export class User extends Model { @Column name!: string; @HasMany(() => Post) posts: Post[]; diff --git a/examples/simple/lib/posts/Post.ts b/examples/simple/lib/posts/Post.ts index 444f5532..714c17f2 100644 --- a/examples/simple/lib/posts/Post.ts +++ b/examples/simple/lib/posts/Post.ts @@ -3,7 +3,7 @@ import {Model, Table, Column, ForeignKey, BelongsTo} from 'sequelize-typescript' import {User} from '../users/User'; @Table -export class Post extends Model { +export class Post extends Model { @Column text!: string; @ForeignKey(() => User) @Column userId!: number; diff --git a/examples/simple/lib/users/User.ts b/examples/simple/lib/users/User.ts index 301dc8df..5b3d0f78 100644 --- a/examples/simple/lib/users/User.ts +++ b/examples/simple/lib/users/User.ts @@ -3,7 +3,7 @@ import {Model, Table, Column, HasMany} from 'sequelize-typescript'; import {Post} from '../posts/Post'; @Table -export class User extends Model { +export class User extends Model { @Column name!: string; @HasMany(() => Post) posts: Post[]; diff --git a/package-lock.json b/package-lock.json index e0201450..6cd8bf94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3123,9 +3123,9 @@ "dev": true }, "sequelize": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.1.1.tgz", - "integrity": "sha512-3ik4crdYtEwApUMwoGRKAz822tFvNts1T5gFDmmJMRAWESr6Eruhni4XHJwcbccrS0D5ifuFKppN2n37M6g0Rg==", + "version": "6.3.5", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.3.5.tgz", + "integrity": "sha512-MiwiPkYSA8NWttRKAXdU9h0TxP6HAc1fl7qZmMO/VQqQOND83G4nZLXd0kWILtAoT9cxtZgFqeb/MPYgEeXwsw==", "dev": true, "requires": { "debug": "^4.1.1", @@ -3143,16 +3143,10 @@ "wkx": "^0.5.0" }, "dependencies": { - "lodash": { - "version": "4.17.19", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", - "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", - "dev": true - }, "moment": { - "version": "2.27.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", - "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==", + "version": "2.28.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.28.0.tgz", + "integrity": "sha512-Z5KOjYmnHyd/ukynmFd/WwyXHd7L4J9vTI/nn5Ap9AVUgaAE15VvQ9MOGmJJygEUklupqIrFnor/tjTwRU+tQw==", "dev": true }, "semver": { @@ -3162,9 +3156,9 @@ "dev": true }, "uuid": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.2.0.tgz", - "integrity": "sha512-CYpGiFTUrmI6OBMkAdjSDM0k5h8SkkiTP4WAjQgDgNB1S3Ou9VBEvr6q0Kv2H1mMk7IWfxYGpMH5sd5AvcIV2Q==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz", + "integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==", "dev": true } } diff --git a/package.json b/package.json index 14b1b974..af45931b 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "nyc": "15.1.0", "prettyjson": "1.2.1", "reflect-metadata": "0.1.9", - "sequelize": "6.1.1", + "sequelize": "6.3.5", "sinon": "1.17.7", "sinon-chai": "2.8.0", "source-map-support": "0.4.14", diff --git a/src/hooks/shared/hooks-service.ts b/src/hooks/shared/hooks-service.ts index 885d347d..4f627e87 100644 --- a/src/hooks/shared/hooks-service.ts +++ b/src/hooks/shared/hooks-service.ts @@ -2,14 +2,14 @@ import 'reflect-metadata'; import {HookMeta} from "./hook-meta"; import {HookOptions} from "./hook-options"; import {SequelizeHooks} from "sequelize/types/lib/hooks"; -import {Model} from "../../model/model/model"; +import {ModelCtor} from "../../model/model/model"; const HOOKS_KEY = 'sequelize:hooks'; /** * Installs hooks on the specified models */ -export function installHooks(models: Array): void { +export function installHooks(models: Array): void { models.forEach(model => { const hooks = getHooks(model); @@ -74,7 +74,7 @@ export function addHook(target: any, hookType: keyof SequelizeHooks, methodName: /** * Install a hook */ -function installHook(model: typeof Model, hook: HookMeta): void { +function installHook(model: ModelCtor, hook: HookMeta): void { if (hook.options && hook.options.name) { model.addHook(hook.hookType, hook.options.name, model[hook.methodName]); return; diff --git a/src/model/model/model.ts b/src/model/model/model.ts index d72aa901..92bd8086 100644 --- a/src/model/model/model.ts +++ b/src/model/model/model.ts @@ -13,7 +13,7 @@ export type ModelCtor = (new () => M) & ModelType; export type $GetType = NonNullable extends any[] ? NonNullable : (NonNullable | null); -export abstract class Model extends OriginModel { +export abstract class Model extends OriginModel { // TODO Consider moving the following props to OriginModel id?: number | any; @@ -30,7 +30,7 @@ export abstract class Model extends OriginModel { return super.init(attributes, options); } - constructor(values?: object, options?: BuildOptions) { + constructor(values?: TCreationAttributes, options?: BuildOptions) { if (!new.target.isInitialized) { throw new ModelNotInitializedError( new.target, diff --git a/src/scopes/scope-service.ts b/src/scopes/scope-service.ts index 1ba87a47..81fb6bd8 100644 --- a/src/scopes/scope-service.ts +++ b/src/scopes/scope-service.ts @@ -1,6 +1,6 @@ import {FindOptions} from "sequelize"; -import {Model} from "../model/model/model"; +import {ModelCtor} from "../model/model/model"; import {deepAssign} from "../shared/object"; import {ScopeOptions, ScopeOptionsGetters, ScopesOptions} from "./scope-options"; import {resolveModelGetter} from '../model/shared/model-service'; @@ -13,7 +13,7 @@ const SCOPES_OPTIONS_KEY = 'sequelize:scopes-options'; /** * Resolves scopes and adds them to the specified models */ -export function resolveScopes(models: Array): void { +export function resolveScopes(models: Array): void { models.forEach(model => { resolvesDeprecatedScopes(model); const {getDefaultScope, getScopes} = getScopeOptionsGetters(model.prototype); @@ -29,7 +29,7 @@ export function resolveScopes(models: Array): void { .forEach(key => resolveScope(key, model, options[key])); }); } -export const resolveScope = (scopeName: string, model: typeof Model, options: ScopesOptions) => { +export const resolveScope = (scopeName: string, model: ModelCtor, options: ScopesOptions) => { if (typeof options === 'function') { const fn = options; options = (...args: any[]) => inferAlias(fn(...args), model); @@ -59,7 +59,7 @@ export const setScopeOptionsGetters = (target: any, options: ScopeOptionsGetters /** * @deprecated */ -export const resolvesDeprecatedScopes = (model: typeof Model) => { +export const resolvesDeprecatedScopes = (model: ModelCtor) => { const options = getScopeOptions(model.prototype) || {}; Object .keys(options) @@ -89,7 +89,7 @@ export function getScopeOptions(target: any): ScopeOptions | undefined { /** * @deprecated */ -function resolveDeprecatedScope(scopeName: string, model: typeof Model, options: ScopeFindOptions | Function | undefined): void { +function resolveDeprecatedScope(scopeName: string, model: ModelCtor, options: ScopeFindOptions | Function | undefined): void { if (typeof options === 'function') { const fn: Function = options; options = (...args: any[]) => inferAlias(fn(...args), model); diff --git a/test/models/Book.ts b/test/models/Book.ts index 99da0bb0..e20fa257 100644 --- a/test/models/Book.ts +++ b/test/models/Book.ts @@ -2,7 +2,7 @@ import {Table, Model, Column, HasMany} from "../../src"; import {Page} from "./Page"; @Table -export class Book extends Model { +export class Book extends Model { @Column title: string; diff --git a/test/models/Box.ts b/test/models/Box.ts index 229f0a0e..526d5b70 100644 --- a/test/models/Box.ts +++ b/test/models/Box.ts @@ -1,7 +1,7 @@ import {Table, Model, Column} from "../../src"; @Table -export class Box extends Model { +export class Box extends Model { @Column length: number; diff --git a/test/models/Hook.ts b/test/models/Hook.ts index bcb428ce..a7a4cec9 100644 --- a/test/models/Hook.ts +++ b/test/models/Hook.ts @@ -44,7 +44,7 @@ import { * Model used to test hook decorators. Defined hooks are mocked out for testing. */ @Table -export class Hook extends Model { +export class Hook extends Model { @Column name: string; diff --git a/test/models/Manufacturer.ts b/test/models/Manufacturer.ts index c7f37fbb..4f567d62 100644 --- a/test/models/Manufacturer.ts +++ b/test/models/Manufacturer.ts @@ -9,7 +9,7 @@ import {ShoeWithScopes} from "./ShoeWithScopes"; } }) @Table -export class Manufacturer extends Model { +export class Manufacturer extends Model { @Column brand: string; diff --git a/test/models/Page.ts b/test/models/Page.ts index de71f466..2b7e516f 100644 --- a/test/models/Page.ts +++ b/test/models/Page.ts @@ -2,7 +2,7 @@ import {Table, Model, ForeignKey, Column, BelongsTo, DataType} from "../../src"; import {Book} from "./Book"; @Table -export class Page extends Model { +export class Page extends Model { @Column(DataType.TEXT) content: string; diff --git a/test/models/Person.ts b/test/models/Person.ts index 0b5f6364..4d034cec 100644 --- a/test/models/Person.ts +++ b/test/models/Person.ts @@ -1,7 +1,7 @@ import {Table, Model, Column, PrimaryKey, DataType, Default} from "../../src"; @Table -export class Person extends Model { +export class Person extends Model { @PrimaryKey @Default(DataType.UUIDV1) diff --git a/test/models/Player.ts b/test/models/Player.ts index 3f2f3f01..32b9c462 100644 --- a/test/models/Player.ts +++ b/test/models/Player.ts @@ -3,7 +3,7 @@ import {Team} from "./Team"; import {Shoe} from "./Shoe"; @Table -export class Player extends Model { +export class Player extends Model { @PrimaryKey @AutoIncrement diff --git a/test/models/Shoe.ts b/test/models/Shoe.ts index a46e4671..0f251fe4 100644 --- a/test/models/Shoe.ts +++ b/test/models/Shoe.ts @@ -6,7 +6,7 @@ export const SHOE_TABLE_NAME = 'Glove'; @Table({ tableName: SHOE_TABLE_NAME }) -export class Shoe extends Model { +export class Shoe extends Model { @Column brand: string; diff --git a/test/models/ShoeWithDeprecatedScopes.ts b/test/models/ShoeWithDeprecatedScopes.ts index c43ffd66..e91b5fc2 100644 --- a/test/models/ShoeWithDeprecatedScopes.ts +++ b/test/models/ShoeWithDeprecatedScopes.ts @@ -19,9 +19,9 @@ export const SHOE_SCOPES = { noImg: { where: {img: null} }, - manufacturerWithScope: { + /*manufacturerWithScope: { include: [() => Manufacturer.scope('brandOnly')] - }, + },*/ primaryColor: primaryColor => ({ where: {primaryColor} } @@ -36,7 +36,7 @@ export const SHOE_SCOPES = { @DefaultScope(SHOE_DEFAULT_SCOPE) @Scopes(SHOE_SCOPES) @Table -export class ShoeWithDeprecatedScopes extends Model { +export class ShoeWithDeprecatedScopes extends Model { @Column readonly secretKey: string; diff --git a/test/models/ShoeWithScopes.ts b/test/models/ShoeWithScopes.ts index 1384dbb2..5d439f54 100644 --- a/test/models/ShoeWithScopes.ts +++ b/test/models/ShoeWithScopes.ts @@ -36,7 +36,7 @@ export const SHOE_SCOPES__GETTER = () => ({ @DefaultScope(SHOE_DEFAULT_SCOPE_GETTER) @Scopes(SHOE_SCOPES__GETTER) @Table -export class ShoeWithScopes extends Model { +export class ShoeWithScopes extends Model { @Column readonly secretKey: string; diff --git a/test/models/ShoeWithValidation.ts b/test/models/ShoeWithValidation.ts index 8c54a3c4..1140960d 100644 --- a/test/models/ShoeWithValidation.ts +++ b/test/models/ShoeWithValidation.ts @@ -27,7 +27,7 @@ export const PRODUCED_AT_IS_BEFORE = '2017-02-27'; export const BRAND_LENGTH = {min: 3, max: 15}; @Table -export class ShoeWithValidation extends Model { +export class ShoeWithValidation extends Model { @IsUUID(UUID_VERSION) @PrimaryKey diff --git a/test/models/Team.ts b/test/models/Team.ts index 6d2a2b1d..4cbf4c0d 100644 --- a/test/models/Team.ts +++ b/test/models/Team.ts @@ -2,7 +2,7 @@ import {Table, Model, PrimaryKey, AutoIncrement, Column, HasMany} from "../../sr import {Player} from "./Player"; @Table -export class Team extends Model { +export class Team extends Model { @PrimaryKey @AutoIncrement diff --git a/test/models/TimeStampsUser.ts b/test/models/TimeStampsUser.ts index 9b29e451..9704668d 100644 --- a/test/models/TimeStampsUser.ts +++ b/test/models/TimeStampsUser.ts @@ -3,7 +3,7 @@ import {Table, Model, PrimaryKey, AutoIncrement, Column} from "../../src"; @Table({ timestamps: true }) -export class TimeStampsUser extends Model { +export class TimeStampsUser extends Model { @PrimaryKey @AutoIncrement diff --git a/test/models/User.ts b/test/models/User.ts index c4c28aaf..44437e19 100644 --- a/test/models/User.ts +++ b/test/models/User.ts @@ -1,7 +1,7 @@ import {Table, Model, PrimaryKey, Column, AutoIncrement, DataType, Default, AllowNull, Unique, Length, IsInt} from "../../src"; @Table -export class User extends Model { +export class User extends Model { @PrimaryKey @AutoIncrement diff --git a/test/models/UserWithCreatedAtButWithoutUpdatedAt.ts b/test/models/UserWithCreatedAtButWithoutUpdatedAt.ts index c57b8da8..37418519 100644 --- a/test/models/UserWithCreatedAtButWithoutUpdatedAt.ts +++ b/test/models/UserWithCreatedAtButWithoutUpdatedAt.ts @@ -4,7 +4,7 @@ import {Table, Model, Column} from "../../src"; timestamps: true, updatedAt: false }) -export class UserWithCreatedAtButWithoutUpdatedAt extends Model { +export class UserWithCreatedAtButWithoutUpdatedAt extends Model { @Column name: string; diff --git a/test/models/UserWithCustomUpdatedAt.ts b/test/models/UserWithCustomUpdatedAt.ts index cb93db95..c5adffe8 100644 --- a/test/models/UserWithCustomUpdatedAt.ts +++ b/test/models/UserWithCustomUpdatedAt.ts @@ -1,7 +1,7 @@ import {Table, Model, Column} from "../../src"; @Table({timestamps: false}) -export class UserWithCustomUpdatedAt extends Model { +export class UserWithCustomUpdatedAt extends Model { @Column name: string; diff --git a/test/models/UserWithNoAutoIncrementation.ts b/test/models/UserWithNoAutoIncrementation.ts index b2a1a316..eddcc7a9 100644 --- a/test/models/UserWithNoAutoIncrementation.ts +++ b/test/models/UserWithNoAutoIncrementation.ts @@ -1,7 +1,7 @@ import {Table, Model, Column, DataType} from "../../src"; @Table -export class UserWithNoAutoIncrementation extends Model { +export class UserWithNoAutoIncrementation extends Model { @Column({ type: DataType.INTEGER.UNSIGNED, diff --git a/test/models/UserWithSwag.ts b/test/models/UserWithSwag.ts index 18e654f6..c6ca31ab 100644 --- a/test/models/UserWithSwag.ts +++ b/test/models/UserWithSwag.ts @@ -1,7 +1,7 @@ import {Table, Model, Column, DataType} from "../../src"; @Table -export class UserWithSwag extends Model { +export class UserWithSwag extends Model { @Column name: string; diff --git a/test/models/UserWithValidation.ts b/test/models/UserWithValidation.ts index 646483bc..30e9aab5 100644 --- a/test/models/UserWithValidation.ts +++ b/test/models/UserWithValidation.ts @@ -1,7 +1,7 @@ import {Table, Model, Column, DataType} from "../../src"; @Table -export class UserWithValidation extends Model { +export class UserWithValidation extends Model { @Column name: string; diff --git a/test/models/UserWithVersion.ts b/test/models/UserWithVersion.ts index 49c60045..09a643b7 100644 --- a/test/models/UserWithVersion.ts +++ b/test/models/UserWithVersion.ts @@ -1,7 +1,7 @@ import {Column, Model, Table} from "../../src"; @Table({version: true}) -export class UserWithVersion extends Model { +export class UserWithVersion extends Model { @Column name: string; diff --git a/test/models/exports/Game.ts b/test/models/exports/Game.ts index 2257c216..0b310ebb 100644 --- a/test/models/exports/Game.ts +++ b/test/models/exports/Game.ts @@ -1,7 +1,7 @@ import {Table, Column, Model} from '../../../src'; @Table -export class Game extends Model { +export class Game extends Model { @Column title: string; diff --git a/test/models/exports/custom-match/match.model.ts b/test/models/exports/custom-match/match.model.ts index 569ac617..6f2f14d5 100644 --- a/test/models/exports/custom-match/match.model.ts +++ b/test/models/exports/custom-match/match.model.ts @@ -4,7 +4,7 @@ export const MatchN = 'Not a model'; export const NMatch = 'Not a model'; @Table -export class Match extends Model { +export class Match extends Model { @Column title: string; diff --git a/test/models/exports/gamer.model.ts b/test/models/exports/gamer.model.ts index 09894951..e1f577d8 100644 --- a/test/models/exports/gamer.model.ts +++ b/test/models/exports/gamer.model.ts @@ -1,7 +1,7 @@ import {Table, Column, Model} from '../../../src'; @Table -export default class Gamer extends Model { +export default class Gamer extends Model { @Column nickname: string; diff --git a/test/models/exports/throws/_cheater.ts b/test/models/exports/throws/_cheater.ts index 60b2b45b..d9acf989 100644 --- a/test/models/exports/throws/_cheater.ts +++ b/test/models/exports/throws/_cheater.ts @@ -1,4 +1,4 @@ import {Table, Model} from '../../../../src'; @Table -export class Cheater extends Model {} +export class Cheater extends Model {} diff --git a/test/models/globs/match-dir-only/PlayerDir.ts b/test/models/globs/match-dir-only/PlayerDir.ts index 7650e09e..9329845f 100644 --- a/test/models/globs/match-dir-only/PlayerDir.ts +++ b/test/models/globs/match-dir-only/PlayerDir.ts @@ -1,7 +1,7 @@ import {Table, Model, Column,} from "../../../../src"; @Table -export default class PlayerDir extends Model { +export default class PlayerDir extends Model { @Column name: string; } diff --git a/test/models/globs/match-dir-only/ShoeDir.ts b/test/models/globs/match-dir-only/ShoeDir.ts index a050a49f..38a5069d 100644 --- a/test/models/globs/match-dir-only/ShoeDir.ts +++ b/test/models/globs/match-dir-only/ShoeDir.ts @@ -1,7 +1,7 @@ import {Table, Model, Column} from "../../../../src"; @Table -export default class ShoeDir extends Model { +export default class ShoeDir extends Model { @Column brand: string; diff --git a/test/models/globs/match-dir-only/TeamDir.ts b/test/models/globs/match-dir-only/TeamDir.ts index 9b478b79..b02f244b 100644 --- a/test/models/globs/match-dir-only/TeamDir.ts +++ b/test/models/globs/match-dir-only/TeamDir.ts @@ -1,7 +1,7 @@ import {Table, Model, Column} from "../../../../src"; @Table -export default class TeamDir extends Model { +export default class TeamDir extends Model { @Column name: string; diff --git a/test/models/globs/match-files/AddressDir.ts b/test/models/globs/match-files/AddressDir.ts index 8ef167ba..c044e93d 100644 --- a/test/models/globs/match-files/AddressDir.ts +++ b/test/models/globs/match-files/AddressDir.ts @@ -2,6 +2,6 @@ import {Model} from "../../../../src"; import {Table} from "../../../../src/model/table/table"; @Table -export class AddressDir extends Model { +export class AddressDir extends Model { } diff --git a/test/models/globs/match-files/UserDir.ts b/test/models/globs/match-files/UserDir.ts index df2cd9ed..6962f11c 100644 --- a/test/models/globs/match-files/UserDir.ts +++ b/test/models/globs/match-files/UserDir.ts @@ -1,6 +1,6 @@ import {Model, Table} from "../../../../src"; @Table -export class UserDir extends Model { +export class UserDir extends Model { } diff --git a/test/models/globs/match-sub-dir-files/players/player.model.ts b/test/models/globs/match-sub-dir-files/players/player.model.ts index b872e135..592cc8f6 100644 --- a/test/models/globs/match-sub-dir-files/players/player.model.ts +++ b/test/models/globs/match-sub-dir-files/players/player.model.ts @@ -1,7 +1,7 @@ import {Table, Model, Column,} from "../../../../../src"; @Table -export default class PlayerGlob extends Model { +export default class PlayerGlob extends Model { @Column name: string; } diff --git a/test/models/globs/match-sub-dir-files/shoes/shoe.model.ts b/test/models/globs/match-sub-dir-files/shoes/shoe.model.ts index c338327e..31a7e547 100644 --- a/test/models/globs/match-sub-dir-files/shoes/shoe.model.ts +++ b/test/models/globs/match-sub-dir-files/shoes/shoe.model.ts @@ -1,7 +1,7 @@ import {Table, Model, Column} from "../../../../../src"; @Table -export default class ShoeGlob extends Model { +export default class ShoeGlob extends Model { @Column brand: string; diff --git a/test/models/globs/match-sub-dir-files/teams/team.model.ts b/test/models/globs/match-sub-dir-files/teams/team.model.ts index a65766ed..eff6f8c3 100644 --- a/test/models/globs/match-sub-dir-files/teams/team.model.ts +++ b/test/models/globs/match-sub-dir-files/teams/team.model.ts @@ -1,7 +1,7 @@ import {Table, Model, Column} from "../../../../../src"; @Table -export default class TeamGlob extends Model { +export default class TeamGlob extends Model { @Column name: string; diff --git a/test/specs/annotations/belongs-to-many.spec.ts b/test/specs/annotations/belongs-to-many.spec.ts index 2613780f..f1e07004 100644 --- a/test/specs/annotations/belongs-to-many.spec.ts +++ b/test/specs/annotations/belongs-to-many.spec.ts @@ -14,10 +14,10 @@ describe('BelongsToMany', () => { const sequelize = createSequelize(false); @Table - class Team extends Model {} + class Team extends Model {} @Table - class Player extends Model { + class Player extends Model { @BelongsToMany(() => Team, { as, diff --git a/test/specs/annotations/belongs-to.spec.ts b/test/specs/annotations/belongs-to.spec.ts index 1f63f045..9d68aa79 100644 --- a/test/specs/annotations/belongs-to.spec.ts +++ b/test/specs/annotations/belongs-to.spec.ts @@ -14,10 +14,10 @@ describe('BelongsTo', () => { const sequelize = createSequelize(false); @Table - class Team extends Model {} + class Team extends Model {} @Table - class Player extends Model { + class Player extends Model { @BelongsTo(() => Team, {as, foreignKey: 'teamId'}) team: Team; @@ -33,10 +33,10 @@ describe('BelongsTo', () => { const _sequelize = createSequelize(false); @Table - class Team extends Model {} + class Team extends Model {} @Table - class Player extends Model { + class Player extends Model { @BelongsTo(() => Team) team: Team; } diff --git a/test/specs/annotations/comment.spec.ts b/test/specs/annotations/comment.spec.ts index dc9f6b8f..32c4e6f2 100644 --- a/test/specs/annotations/comment.spec.ts +++ b/test/specs/annotations/comment.spec.ts @@ -10,7 +10,7 @@ describe("comment", () => { const BookTitleCommentString = "title for book"; @Table - class Book extends Model { + class Book extends Model { @Comment(BookTitleCommentString) @Column title: string; diff --git a/test/specs/annotations/has-many.spec.ts b/test/specs/annotations/has-many.spec.ts index 1252e265..357eb458 100644 --- a/test/specs/annotations/has-many.spec.ts +++ b/test/specs/annotations/has-many.spec.ts @@ -14,10 +14,10 @@ describe('HasMany', () => { const sequelize = createSequelize(false); @Table - class Player extends Model {} + class Player extends Model {} @Table - class Team extends Model { + class Team extends Model { @HasMany(() => Player, { as, diff --git a/test/specs/annotations/has-one.spec.ts b/test/specs/annotations/has-one.spec.ts index 51a112d3..22c94781 100644 --- a/test/specs/annotations/has-one.spec.ts +++ b/test/specs/annotations/has-one.spec.ts @@ -14,10 +14,10 @@ describe('HasOne', () => { const sequelize = createSequelize(false); @Table - class Player extends Model {} + class Player extends Model {} @Table - class Team extends Model { + class Team extends Model { @HasOne(() => Player, { as, diff --git a/test/specs/association.spec.ts b/test/specs/association.spec.ts index 99cb3add..2431a6f2 100644 --- a/test/specs/association.spec.ts +++ b/test/specs/association.spec.ts @@ -18,22 +18,22 @@ use(chaiAsPromised); const Association: any = OriginSequelize['Association']; /* Some base classes that we can override later */ -class ConcreteModel> extends Model { +class ConcreteModel extends Model { } -class BookModel extends ConcreteModel { +class BookModel extends ConcreteModel { title: string; pages: PageModel[]; authors: AuthorModel[]; } -class PageModel extends ConcreteModel { +class PageModel extends ConcreteModel { content: string; bookId: number; book: BookModel; } -class AuthorModel extends ConcreteModel { +class AuthorModel extends ConcreteModel { name: string; books: BookWithAuthorModel[]; } @@ -575,7 +575,7 @@ describe('association', () => { describe('resolve foreign keys automatically', () => { @Table - class Book extends Model implements BookModel { + class Book extends Model implements BookModel { @Column title: string; @@ -587,7 +587,7 @@ describe('association', () => { } @Table - class Page extends Model implements PageModel { + class Page extends Model implements PageModel { @Column(DataType.TEXT) content: string; @@ -605,7 +605,7 @@ describe('association', () => { describe('set foreign keys explicitly', () => { @Table - class Book2 extends Model implements BookModel { + class Book2 extends Model implements BookModel { @Column title: string; @@ -617,7 +617,7 @@ describe('association', () => { } @Table - class Page2 extends Model implements PageModel { + class Page2 extends Model implements PageModel { @Column(DataType.TEXT) content: string; @@ -715,7 +715,7 @@ describe('association', () => { describe('resolve foreign keys automatically with association options', () => { @Table - class Book3 extends Model implements BookModel { + class Book3 extends Model implements BookModel { @Column title: string; @@ -727,7 +727,7 @@ describe('association', () => { } @Table - class Page3 extends Model implements PageModel { + class Page3 extends Model implements PageModel { @Column(DataType.TEXT) content: string; @@ -745,7 +745,7 @@ describe('association', () => { describe('set foreign keys explicitly with association options', () => { @Table - class Book4 extends Model implements BookModel { + class Book4 extends Model implements BookModel { @Column title: string; @@ -757,7 +757,7 @@ describe('association', () => { } @Table - class Page4 extends Model implements PageModel { + class Page4 extends Model implements PageModel { @Column(DataType.TEXT) content: string; @@ -775,7 +775,7 @@ describe('association', () => { describe('set foreign keys explicitly via options', () => { @Table - class Book5 extends Model implements BookModel { + class Book5 extends Model implements BookModel { @Column title: string; @@ -787,7 +787,7 @@ describe('association', () => { } @Table - class Page5 extends Model implements PageModel { + class Page5 extends Model implements PageModel { @Column(DataType.TEXT) content: string; @@ -806,11 +806,11 @@ describe('association', () => { const _sequelize = createSequelize(false); @Table - class Friend extends Model { + class Friend extends Model { } @Table - class User extends Model { + class User extends Model { @HasOne(() => Friend, 'userId') friend: Friend; @@ -1285,7 +1285,7 @@ describe('association', () => { } @Table - class AuthorBook extends Model { + class AuthorBook extends Model { @ForeignKey(() => Book) bookId: number; @@ -1296,7 +1296,7 @@ describe('association', () => { } @Table - class Author extends Model { + class Author extends Model { @Column name: string; @@ -1323,7 +1323,7 @@ describe('association', () => { } @Table - class AuthorBook4 extends Model { + class AuthorBook4 extends Model { @ForeignKey(() => Book4) bookId: number; @@ -1333,7 +1333,7 @@ describe('association', () => { } @Table - class Author4 extends Model { + class Author4 extends Model { @Column name: string; @@ -1360,7 +1360,7 @@ describe('association', () => { } @Table - class Author2 extends Model { + class Author2 extends Model { @Column name: string; @@ -1389,7 +1389,7 @@ describe('association', () => { } @Table - class Author3 extends Model { + class Author3 extends Model { @Column name: string; @@ -1408,7 +1408,7 @@ describe('association', () => { describe('set through model via through options', () => { @Table - class Book66 extends Model { + class Book66 extends Model { @Column title: string; @@ -1424,7 +1424,7 @@ describe('association', () => { } @Table - class AuthorBook66 extends Model { + class AuthorBook66 extends Model { @ForeignKey(() => Book66) bookId: number; @@ -1434,7 +1434,7 @@ describe('association', () => { } @Table - class Author66 extends Model { + class Author66 extends Model { @Column name: string; @@ -1453,7 +1453,7 @@ describe('association', () => { describe('set through model string via through options', () => { @Table - class Book66 extends Model { + class Book66 extends Model { @Column title: string; @@ -1471,7 +1471,7 @@ describe('association', () => { } @Table - class Author66 extends Model { + class Author66 extends Model { @Column name: string; @@ -1492,7 +1492,7 @@ describe('association', () => { describe('ThroughOptions', () => { @Table - class User77 extends Model { + class User77 extends Model { @Column name: string; @@ -1513,7 +1513,7 @@ describe('association', () => { } @Table - class Subscription extends Model { + class Subscription extends Model { @PrimaryKey @ForeignKey(() => User77) @@ -1542,15 +1542,15 @@ describe('association', () => { const _sequelize = createSequelize(false); @Table - class UserFriend extends Model { + class UserFriend extends Model { } @Table - class Friend extends Model { + class Friend extends Model { } @Table - class User extends Model { + class User extends Model { @BelongsToMany(() => Friend, () => UserFriend) friend: Friend; @@ -1599,12 +1599,12 @@ describe('association', () => { country: 'United States', }; - class AbstractUser extends Model { + class AbstractUser extends Model { name: string; address: AbstractAddress; } - class AbstractAddress extends Model { + class AbstractAddress extends Model { street: string; zipCode: string; city: string; @@ -1859,7 +1859,7 @@ describe('association', () => { describe('resolve foreign keys automatically', () => { @Table - class User extends Model { + class User extends Model { @Column name: string; @@ -1869,7 +1869,7 @@ describe('association', () => { } @Table - class Address extends Model
{ + class Address extends Model { @Column street: string; @@ -1896,7 +1896,7 @@ describe('association', () => { describe('set foreign keys explicitly', () => { @Table - class User2 extends Model { + class User2 extends Model { @Column name: string; @@ -1906,7 +1906,7 @@ describe('association', () => { } @Table - class Address2 extends Model { + class Address2 extends Model { @Column street: string; @@ -1998,7 +1998,7 @@ describe('association', () => { const ON_DELETE_ACTION = 'SET NULL'; @Table - class User3 extends Model { + class User3 extends Model { @Column name: string; @@ -2008,7 +2008,7 @@ describe('association', () => { } @Table - class Address3 extends Model { + class Address3 extends Model { @Column street: string; @@ -2037,7 +2037,7 @@ describe('association', () => { describe('set foreign keys explicitly with association options', () => { @Table - class User4 extends Model { + class User4 extends Model { @Column name: string; @@ -2047,7 +2047,7 @@ describe('association', () => { } @Table - class Address4 extends Model { + class Address4 extends Model { @Column street: string; @@ -2076,7 +2076,7 @@ describe('association', () => { describe('set foreign keys explicitly via options', () => { @Table - class User5 extends Model { + class User5 extends Model { @Column name: string; @@ -2086,7 +2086,7 @@ describe('association', () => { } @Table - class Address5 extends Model { + class Address5 extends Model { @Column street: string; @@ -2112,7 +2112,7 @@ describe('association', () => { describe('set foreign keys explicitly with association options (allowNull: false on foreignKey)', () => { @Table - class User6 extends Model { + class User6 extends Model { @Column name: string; @@ -2122,7 +2122,7 @@ describe('association', () => { } @Table - class Address6 extends Model { + class Address6 extends Model { @Column street: string; diff --git a/test/specs/hooks/hooks.spec.ts b/test/specs/hooks/hooks.spec.ts index d9e57262..ad57e49c 100644 --- a/test/specs/hooks/hooks.spec.ts +++ b/test/specs/hooks/hooks.spec.ts @@ -27,7 +27,7 @@ describe('hook', () => { it('should throw on non-static hooks', () => { expect(() => { @Table - class User extends Model { + class User extends Model { @Column firstName: string; @@ -45,7 +45,7 @@ describe('hook', () => { expect(() => { // tslint:disable-next-line:max-classes-per-file @Table - class User extends Model { + class User extends Model { @Column firstName: string; diff --git a/test/specs/index.spec.ts b/test/specs/index.spec.ts index 24933a10..cb590645 100644 --- a/test/specs/index.spec.ts +++ b/test/specs/index.spec.ts @@ -16,7 +16,7 @@ before(() => { describe('built-in index decorator', () => { it('creates index', async () => { @Table - class Test extends Model { + class Test extends Model { @Index @Column field: string; @@ -34,7 +34,7 @@ describe('built-in index decorator', () => { it('creates multiple indexes', async () => { @Table - class Test extends Model { + class Test extends Model { @Index @Column fieldA: string; @@ -57,7 +57,7 @@ describe('built-in index decorator', () => { it('creates named index', async () => { @Table - class Test extends Model { + class Test extends Model { @Index('my-index') @Column field: string; @@ -75,7 +75,7 @@ describe('built-in index decorator', () => { it('adds multiple fields to the same index', async () => { @Table - class Test extends Model { + class Test extends Model { @Index('my-index') @Column fieldA: string; @@ -97,7 +97,7 @@ describe('built-in index decorator', () => { it('sets extra options for index', async () => { @Table - class Test extends Model { + class Test extends Model { @Index({ name: 'my-index', unique: true, @@ -122,7 +122,7 @@ describe('built-in index decorator', () => { it('sets extra options for field', async () => { @Table - class Test extends Model { + class Test extends Model { @Index({ name: 'my-index', order: 'ASC', @@ -157,7 +157,7 @@ describe('custom index decorator', () => { const OtherIndex = createIndexDecorator(); @Table - class Test extends Model { + class Test extends Model { @MyIndex @Column fieldA: string; @@ -190,7 +190,7 @@ describe('custom index decorator', () => { }); @Table - class Test extends Model { + class Test extends Model { @MyIndex @Column field: string; @@ -213,7 +213,7 @@ describe('custom index decorator', () => { const MyIndex = createIndexDecorator({ name: 'my-index' }); @Table - class Test extends Model { + class Test extends Model { @MyIndex({ order: 'ASC', collate: 'NOCASE' }) @Column fieldA: string; diff --git a/test/specs/instance-methods.spec.ts b/test/specs/instance-methods.spec.ts index 310aa4ef..03306def 100644 --- a/test/specs/instance-methods.spec.ts +++ b/test/specs/instance-methods.spec.ts @@ -7,7 +7,7 @@ describe('instance-methods', () => { let sequelize; @Table - class User extends Model { + class User extends Model { @Column firstName: string; diff --git a/test/specs/instance.spec.ts b/test/specs/instance.spec.ts index eed49365..a6eea1af 100644 --- a/test/specs/instance.spec.ts +++ b/test/specs/instance.spec.ts @@ -1448,7 +1448,7 @@ describe('instance', () => { timestamps: true, createdAt: false }) - class User2 extends Model { + class User2 extends Model { @Column username: string; @@ -1471,7 +1471,7 @@ describe('instance', () => { @Table({ timestamps: true }) - class User3 extends Model { + class User3 extends Model { @Column username: string; @@ -1584,7 +1584,7 @@ describe('instance', () => { it('saves a record with no primary key', () => { @Table - class HistoryLog extends Model { + class HistoryLog extends Model { @Column someText: string; @@ -1610,7 +1610,7 @@ describe('instance', () => { describe('eagerly loaded objects', () => { @Table - class UserEager extends Model { + class UserEager extends Model { @Column username: string; @@ -1623,7 +1623,7 @@ describe('instance', () => { } @Table - class ProjectEager extends Model { + class ProjectEager extends Model { @Column title: string; @@ -1775,7 +1775,7 @@ describe('instance', () => { describe('toJSON', () => { @Table - class NiceUser extends Model { + class NiceUser extends Model { @Column username: string; @@ -1791,7 +1791,7 @@ describe('instance', () => { } @Table - class NiceProject extends Model { + class NiceProject extends Model { @Column title: string; @@ -1916,7 +1916,7 @@ describe('instance', () => { describe('findAll', () => { @Table({timestamps: true, paranoid: true}) - class ParanoidUser extends Model { + class ParanoidUser extends Model { @Column username: string; @@ -2044,7 +2044,7 @@ describe('instance', () => { it('destroys a record with a primary key of something other than id', () => { @Table - class UserDestroy extends Model { + class UserDestroy extends Model { @PrimaryKey @Column @@ -2136,7 +2136,7 @@ describe('instance', () => { it('returns null for null, undefined, and unset boolean values', () => { @Table({logging: true} as TableOptions) - class Setting extends Model { + class Setting extends Model { @Column settingKey: string; @@ -2182,7 +2182,7 @@ describe('instance', () => { it('does not compare the existence of associations', () => { @Table - class UserAssociationEqual extends Model { + class UserAssociationEqual extends Model { @Column username: string; @@ -2193,7 +2193,7 @@ describe('instance', () => { } @Table - class ProjectAssociationEqual extends Model { + class ProjectAssociationEqual extends Model { @Column title: string; @@ -2245,7 +2245,7 @@ describe('instance', () => { it('returns all values', () => { @Table({logging: false} as TableOptions) - class UserHelper extends Model { + class UserHelper extends Model { @Column username: string; @@ -2292,7 +2292,7 @@ describe('instance', () => { it('does not set the deletedAt date in subsequent destroys if dao is paranoid', () => { @Table({timestamps: true, paranoid: true}) - class UserDestroy extends Model { + class UserDestroy extends Model { @Column name: string; @@ -2322,7 +2322,7 @@ describe('instance', () => { it('deletes a record from the database if dao is not paranoid', () => { @Table - class UserDestroy extends Model { + class UserDestroy extends Model { @Column name: string; @@ -2349,7 +2349,7 @@ describe('instance', () => { it('allows sql logging of delete statements', () => { @Table({paranoid: true}) - class UserDelete extends Model { + class UserDelete extends Model { @Column name: string; @@ -2377,7 +2377,7 @@ describe('instance', () => { it('delete a record of multiple primary keys table', () => { @Table - class MultiPrimary extends Model { + class MultiPrimary extends Model { @PrimaryKey @Column(DataType.CHAR(2)) @@ -2429,7 +2429,7 @@ describe('instance', () => { it('restores a previously deleted model', () => { @Table({timestamps: true, paranoid: true}) - class ParanoidUser2 extends Model { + class ParanoidUser2 extends Model { @Column username: string; diff --git a/test/specs/model-methods.spec.ts b/test/specs/model-methods.spec.ts index d7b8825c..fbf26382 100644 --- a/test/specs/model-methods.spec.ts +++ b/test/specs/model-methods.spec.ts @@ -7,7 +7,7 @@ describe('model-methods', () => { let sequelize; @Table - class User extends Model { + class User extends Model { @Column firstName: string; diff --git a/test/specs/model.spec.ts b/test/specs/model.spec.ts index cb3aae43..30088015 100644 --- a/test/specs/model.spec.ts +++ b/test/specs/model.spec.ts @@ -28,7 +28,7 @@ describe('model', () => { let sequelize; @Table - class MainUser extends Model { + class MainUser extends Model { @Column username: string; @@ -67,7 +67,7 @@ describe('model', () => { it('should throw an error', () => { @Table - class Test extends Model { + class Test extends Model { } expect(() => new Test()).to.throw(/^Model not initialized/); @@ -79,7 +79,7 @@ describe('model', () => { it('should throw an error', () => { @Table - class Test extends Model { + class Test extends Model { } expect(() => Test.beforeCreate(() => { @@ -92,7 +92,7 @@ describe('model', () => { it('uses the passed dao name as tablename if freezeTableName', () => { @Table({freezeTableName: true, tableName: 'FrozenUser'}) - class User extends Model { + class User extends Model { } sequelize.addModels([User]); @@ -102,7 +102,7 @@ describe('model', () => { it('uses the pluralized dao name as tablename unless freezeTableName', () => { @Table({freezeTableName: false, tableName: 'SuperUser'}) - class User extends Model { + class User extends Model { } sequelize.addModels([User]); @@ -114,7 +114,7 @@ describe('model', () => { (() => { @Table({freezeTableName: false, tableName: 'SuperUser'}) - class User extends Model { + class User extends Model { } sequelize.addModels([User]); @@ -124,7 +124,7 @@ describe('model', () => { (() => { @Table({freezeTableName: false, tableName: 'SuperUser'}) - class User extends Model { + class User extends Model { } sequelize.addModels([User]); @@ -136,7 +136,7 @@ describe('model', () => { it('allows us us to predefine the ID column with our own specs', () => { @Table - class User extends Model { + class User extends Model { @PrimaryKey @Default('User') @Column @@ -153,7 +153,7 @@ describe('model', () => { it('throws an error if 2 autoIncrements are passed', () => { expect(() => { @Table - class User extends Model { + class User extends Model { @PrimaryKey @AutoIncrement @Column @@ -173,7 +173,7 @@ describe('model', () => { // it('throws an error if a custom model-wide validation is not a function', () => { // expect(() => { // @Table - // class User extends Model { + // class User extends Model { // @Column({ // validate: { // notFunction: 33 @@ -188,7 +188,7 @@ describe('model', () => { // it('throws an error if a custom model-wide validation has the same name as a field', () => { // expect(() => { // @Table - // class User extends Model { + // class User extends Model { // @Column({ // validate: { // field: () => null @@ -204,7 +204,7 @@ describe('model', () => { clock.restore(); @Table({timestamps: true}) - class User extends Model { + class User extends Model { @Column aNumber: number; @@ -243,7 +243,7 @@ describe('model', () => { const defaultFunction = stub().returns(5); @Table({timestamps: true}) - class User extends Model { + class User extends Model { @Default(defaultFunction) @Column aNumber: number; @@ -264,7 +264,7 @@ describe('model', () => { it('should allow me to override updatedAt, createdAt, and deletedAt fields', () => { @Table - class User extends Model { + class User extends Model { @Column aNumber: number; @@ -295,7 +295,7 @@ describe('model', () => { it('should allow me to disable some of the timestamp fields', () => { @Table({updatedAt: false, createdAt: false}) - class User extends Model { + class User extends Model { @Column name: string; @@ -329,7 +329,7 @@ describe('model', () => { const titleSetter = spy(); @Table({updatedAt: false, createdAt: false}) - class Task extends Model { + class Task extends Model { @Column({ type: DataType.STRING(50), allowNull: false, @@ -355,7 +355,7 @@ describe('model', () => { it('should work with both paranoid and underscored being true', () => { @Table({paranoid: true, underscored: true}) - class User extends Model { + class User extends Model { @Column aNumber: number; } @@ -373,7 +373,7 @@ describe('model', () => { it('allows multiple column unique keys to be defined', () => { @Table - class User extends Model { + class User extends Model { @Column({ unique: 'user_and_email' @@ -408,7 +408,7 @@ describe('model', () => { it('allows unique on column with field aliases', () => { @Table - class User extends Model { + class User extends Model { @Column({ field: 'user_name', @@ -433,7 +433,7 @@ describe('model', () => { it('allows us to customize the error message for unique constraint', () => { @Table - class User extends Model { + class User extends Model { @Column({ unique: {name: 'user_and_email', msg: 'User and email must be unique'} @@ -477,7 +477,7 @@ describe('model', () => { } ] }) - class User extends Model { + class User extends Model { @Column userId: number; @@ -491,7 +491,7 @@ describe('model', () => { return User.sync({force: true}).then(() => { // Redefine the model to use the index in database and override error message @Table({timestamps: true}) - class User extends Model { + class User extends Model { @Column({ unique: {name: 'user_and_email_index', msg: 'User and email must be unique'} @@ -538,7 +538,7 @@ describe('model', () => { }], engine: 'MyISAM' } as TableOptions) - class ModelA extends Model { + class ModelA extends Model { @Column fieldA: string; @Column @@ -583,7 +583,7 @@ describe('model', () => { const name = 'test'; @Table - class User extends Model { + class User extends Model { @Column name: string; } @@ -606,7 +606,7 @@ describe('model', () => { it('fills the objects with default values (timestamps=true)', () => { @Table({timestamps: true}) - class Task extends Model { + class Task extends Model { @Default('a task!') @Column @@ -639,7 +639,7 @@ describe('model', () => { it('fills the objects with default values', () => { @Table - class Task extends Model { + class Task extends Model { @Default('a task!') @Column @@ -672,7 +672,7 @@ describe('model', () => { it('attaches getter and setter methods from attribute definition', () => { @Table - class Product extends Model { + class Product extends Model { @Column({ get(this: Product): string { @@ -698,7 +698,7 @@ describe('model', () => { it('uses get/set accessors', () => { @Table - class Product extends Model { + class Product extends Model { @Column(DataType.INTEGER) get priceInCents() { @@ -725,7 +725,7 @@ describe('model', () => { it('should support basic includes', () => { @Table - class Product extends Model { + class Product extends Model { @Column title: string; @@ -747,7 +747,7 @@ describe('model', () => { } @Table - class Tag extends Model { + class Tag extends Model { id: number; @@ -759,7 +759,7 @@ describe('model', () => { } @Table - class User extends Model { + class User extends Model { @Column firstName: string; @@ -801,7 +801,7 @@ describe('model', () => { it('should support includes with aliases', () => { @Table - class Product extends Model { + class Product extends Model { @Column title: string; @@ -817,7 +817,7 @@ describe('model', () => { } @Table - class Tag extends Model { + class Tag extends Model { id: number; @@ -829,7 +829,7 @@ describe('model', () => { } @Table - class User extends Model { + class User extends Model { id: number; @@ -905,7 +905,7 @@ describe('model', () => { it('should not fail if model is paranoid and where is an empty array', () => { @Table({paranoid: true, timestamps: true}) - class User extends Model { + class User extends Model { @Column username: string; @@ -927,7 +927,7 @@ describe('model', () => { it('should filter based on the where clause even if IFindOptions.include is []', () => { @Table({paranoid: true, timestamps: true}) - class User extends Model { + class User extends Model { @Column username: string; @@ -1049,7 +1049,7 @@ describe('model', () => { describe('update', () => { it('throws an error if no where clause is given', () => { @Table - class User extends Model { + class User extends Model { @Column username: string; @@ -1094,7 +1094,7 @@ describe('model', () => { it('updates the attributes that we select only without updating createdAt', () => { @Table({timestamps: true, paranoid: true}) - class User extends Model { + class User extends Model { @Column username: string; diff --git a/test/specs/models/sequelize.spec.ts b/test/specs/models/sequelize.spec.ts index 092ce299..0f73330d 100644 --- a/test/specs/models/sequelize.spec.ts +++ b/test/specs/models/sequelize.spec.ts @@ -140,7 +140,7 @@ describe('sequelize', () => { it('should set define options for models', () => { @Table - class User extends Model { + class User extends Model { } sequelizeFromUriObject.addModels([User]); @@ -259,7 +259,7 @@ describe('sequelize', () => { describe('Add model references', () => { it('should load models from constructor references', () => { @Table - class Test extends Model { + class Test extends Model { } const sequelize1 = new Sequelize({ @@ -274,7 +274,7 @@ describe('sequelize', () => { }); it('should load models from references passed to addModels', () => { @Table - class Test extends Model { + class Test extends Model { } const sequelize1 = new Sequelize({ diff --git a/test/specs/repository-mode.spec.ts b/test/specs/repository-mode.spec.ts index 7236af76..bbdb4ed2 100644 --- a/test/specs/repository-mode.spec.ts +++ b/test/specs/repository-mode.spec.ts @@ -25,7 +25,7 @@ describe('repository-mode', () => { describe('simple setup', () => { @Table - class User extends Model { + class User extends Model { @Column name: string; @Column birthday: Date; } @@ -90,14 +90,14 @@ describe('repository-mode', () => { type _Address = Partial
; @Table - class User extends Model { + class User extends Model { @Column name: string; @Column birthday: Date; @HasOne(() => Address) address: _Address; } @Table - class Address extends Model
{ + class Address extends Model { @Column street: string; @Column city: string; @ForeignKey(() => User) userId: number; @@ -140,7 +140,7 @@ describe('repository-mode', () => { describe('one-to-many', () => { @Table - class User extends Model { + class User extends Model { @Column name: string; @Column birthday: Date; @@ -149,7 +149,7 @@ describe('repository-mode', () => { } @Table - class Comment extends Model { + class Comment extends Model { @Column text: string; @ForeignKey(() => User) @@ -220,19 +220,19 @@ describe('repository-mode', () => { describe('many-to-many', () => { @Table - class UserEvent extends Model { + class UserEvent extends Model { @ForeignKey(() => User) @Column userId: number; @ForeignKey(() => Event) @Column eventId: number; } @Table - class Event extends Model { + class Event extends Model { @Column name: string; @BelongsToMany(() => User, () => UserEvent) users: any[]; } @Table - class User extends Model { + class User extends Model { @Column name: string; @BelongsToMany(() => Event, () => UserEvent) events: Event[]; } diff --git a/test/specs/scopes.spec.ts b/test/specs/scopes.spec.ts index f9256b33..ef55fd1d 100644 --- a/test/specs/scopes.spec.ts +++ b/test/specs/scopes.spec.ts @@ -255,7 +255,7 @@ describe('scopes', () => { updated: {where: {updated: {[Op.gt]: new Date(2000, 1)}}}, }) @Table - class _Person extends Model<_Person> { + class _Person extends Model { @Column name: string; diff --git a/test/specs/services/association.spec.ts b/test/specs/services/association.spec.ts index de4d5145..9a7866d6 100644 --- a/test/specs/services/association.spec.ts +++ b/test/specs/services/association.spec.ts @@ -11,7 +11,7 @@ describe('service.association', () => { it('should add foreign key to target metadata', () => { const target = {}; const FOREIGN_KEY = 'testId'; - const RELATED_CLASS_GETTER = () => class T extends Model {}; + const RELATED_CLASS_GETTER = () => class T extends Model {}; addForeignKey(target, RELATED_CLASS_GETTER, FOREIGN_KEY); const foreignKeys = getForeignKeys(target); @@ -27,7 +27,7 @@ describe('service.association', () => { const target = Object.create(parent); const FOREIGN_KEY = 'testId'; const PARENT_FOREIGN_KEY = 'parentTestId'; - const RELATED_CLASS_GETTER = () => class T extends Model {}; + const RELATED_CLASS_GETTER = () => class T extends Model {}; addForeignKey(parent, RELATED_CLASS_GETTER, PARENT_FOREIGN_KEY); addForeignKey(target, RELATED_CLASS_GETTER, FOREIGN_KEY); diff --git a/test/specs/table_column.spec.ts b/test/specs/table_column.spec.ts index d2f8a5b2..f9fb8738 100644 --- a/test/specs/table_column.spec.ts +++ b/test/specs/table_column.spec.ts @@ -202,7 +202,7 @@ describe('table_column', () => { const seq = createSequelize(false); @Table({timestamps: false}) - class Bottle extends Model { + class Bottle extends Model { @Column(DataType.STRING(5)) brand: string; @@ -233,7 +233,7 @@ describe('table_column', () => { describe('get', () => { @Table - class User extends Model { + class User extends Model { @Column get name(): string { @@ -275,7 +275,7 @@ describe('table_column', () => { describe('set', () => { @Table - class User extends Model { + class User extends Model { @Column get name(): string { diff --git a/test/specs/unique.spec.ts b/test/specs/unique.spec.ts index 6849ff9f..8da972a9 100644 --- a/test/specs/unique.spec.ts +++ b/test/specs/unique.spec.ts @@ -12,7 +12,7 @@ describe('unique decorator', () => { before(() => { @Table - class UserModel extends Model { + class UserModel extends Model { @Unique('test') @Column name: string; @Unique @Column key: string; } diff --git a/test/specs/validation.spec.ts b/test/specs/validation.spec.ts index 0408d7c2..02df36e5 100644 --- a/test/specs/validation.spec.ts +++ b/test/specs/validation.spec.ts @@ -199,7 +199,7 @@ describe('validation', () => { it('should not produce an error', () => { @Table - class User extends Model { + class User extends Model { @Length({min: 0, max: 5}) @Column name: string; } @@ -212,7 +212,7 @@ describe('validation', () => { it('should produce an error due to unfulfilled max', () => { @Table - class User extends Model { + class User extends Model { @Length({min: 0, max: 5}) @Column name: string; } @@ -225,7 +225,7 @@ describe('validation', () => { it('should produce an error due to unfulfilled min', () => { @Table - class User extends Model { + class User extends Model { @Length({min: 5, max: 5}) @Column name: string; } @@ -238,7 +238,7 @@ describe('validation', () => { it('should not produce an error (max only)', () => { @Table - class User extends Model { + class User extends Model { @Length({max: 5}) @Column name: string; } @@ -251,7 +251,7 @@ describe('validation', () => { it('should produce an error (max only)', () => { @Table - class User extends Model { + class User extends Model { @Length({max: 5}) @Column name: string; } @@ -264,7 +264,7 @@ describe('validation', () => { it('should not produce an error (min only)', () => { @Table - class User extends Model { + class User extends Model { @Length({min: 4}) @Column name: string; } @@ -277,7 +277,7 @@ describe('validation', () => { it('should produce an error (min only)', () => { @Table - class User extends Model { + class User extends Model { @Length({min: 5}) @Column name: string; } @@ -294,7 +294,7 @@ describe('validation', () => { it('should not produce an error', () => { @Table - class User extends Model { + class User extends Model { @NotEmpty @Column name: string; } @@ -307,7 +307,7 @@ describe('validation', () => { it('should produce an error', () => { @Table - class User extends Model { + class User extends Model { @NotEmpty @Column name: string; } @@ -320,7 +320,7 @@ describe('validation', () => { it('should not produce an error (with msg)', () => { @Table - class User extends Model { + class User extends Model { @NotEmpty({msg: 'NotEmpty'}) @Column name: string; } @@ -333,7 +333,7 @@ describe('validation', () => { it('should produce an error (with msg)', () => { @Table - class User extends Model { + class User extends Model { @NotEmpty({msg: 'NotEmpty'}) @Column name: string; } @@ -354,7 +354,7 @@ describe('validation', () => { let _sequelize; @Table - class User extends Model { + class User extends Model { @Column name: string; @Validator userValidator(): void { @@ -392,7 +392,7 @@ describe('validation', () => { let _sequelize; @Table - class User extends Model { + class User extends Model { @Column name: string; @Column age: number; diff --git a/test/types/model.spec.ts b/test/types/model.spec.ts index 14bbf90b..c1a7bed9 100644 --- a/test/types/model.spec.ts +++ b/test/types/model.spec.ts @@ -6,7 +6,7 @@ import {Table} from '../../src/model/table/table'; import {DataType} from '../../src/sequelize/data-type/data-type'; @Table -export class User extends Model { +export class User extends Model { @Column(DataType.ARRAY(DataType.STRING)) myCol: string[]; } diff --git a/test/types/scopes.spec.ts b/test/types/scopes.spec.ts index 7c035d63..f5c57191 100644 --- a/test/types/scopes.spec.ts +++ b/test/types/scopes.spec.ts @@ -16,7 +16,7 @@ import {DefaultScope} from "../../src/scopes/default-scope"; } })) @Table -export class User extends Model { +export class User extends Model { @Column(DataType.ARRAY(DataType.STRING)) myCol: string[]; }