Type server models (#6326)
* fix: type server models * fix: make ParanoidModel generic * fix: ApiKey * fix: Attachment * fix: AuthenticationProvider * fix: Backlink * fix: Collection * fix: Comment * fix: Document * fix: FileOperation * fix: Group * fix: GroupPermission * fix: GroupUser * fix: Integration * fix: IntegrationAuthentication * fix: Notification * fix: Pin * fix: Revision * fix: SearchQuery * fix: Share * fix: Star * fix: Subscription * fix: TypeError * fix: Imports * fix: Team * fix: TeamDomain * fix: User * fix: UserAuthentication * fix: UserPermission * fix: View * fix: WebhookDelivery * fix: WebhookSubscription * Remove type duplication --------- Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import path from "path";
|
||||
import { Model, Sequelize } from "sequelize-typescript";
|
||||
import { InferAttributes, InferCreationAttributes } from "sequelize";
|
||||
import { Sequelize } from "sequelize-typescript";
|
||||
import { Umzug, SequelizeStorage, MigrationError } from "umzug";
|
||||
import env from "@server/env";
|
||||
import Model from "@server/models/base/Model";
|
||||
import Logger from "../logging/Logger";
|
||||
import * as models from "../models";
|
||||
|
||||
@@ -12,7 +14,12 @@ const url = env.DATABASE_CONNECTION_POOL_URL || env.DATABASE_URL;
|
||||
|
||||
export function createDatabaseInstance(
|
||||
url: string,
|
||||
models: { [key: string]: typeof Model }
|
||||
models: {
|
||||
[key: string]: typeof Model<
|
||||
InferAttributes<Model>,
|
||||
InferCreationAttributes<Model>
|
||||
>;
|
||||
}
|
||||
) {
|
||||
return new Sequelize(url, {
|
||||
logging: (msg) =>
|
||||
@@ -28,7 +35,7 @@ export function createDatabaseInstance(
|
||||
}
|
||||
: false,
|
||||
},
|
||||
models: Object.values(models) as any,
|
||||
models: Object.values(models),
|
||||
pool: {
|
||||
max: poolMax,
|
||||
min: poolMin,
|
||||
|
||||
Reference in New Issue
Block a user