remove namespace

This commit is contained in:
hmacr committed 2025-01-17 06:52:22 +05:30
1 parent 33bd2950be
commit ebb92cfa88
8 files changed
+3 -19

No files matched your search

-2
View File
@@ -36,8 +36,6 @@ class Attachment extends IdModel<
InferAttributes<Attachment>,
Partial<InferCreationAttributes<Attachment>>
> {
static eventNamespace = "attachments";
@Length({
max: 4096,
msg: "key must be 4096 characters or less",
-2
View File
@@ -42,8 +42,6 @@ class Comment extends ParanoidModel<
InferAttributes<Comment>,
Partial<InferCreationAttributes<Comment>>
> {
static eventNamespace = "comments";
@TextLength({
max: CommentValidation.maxLength,
msg: `Comment must be less than ${CommentValidation.maxLength} characters`,
-2
View File
@@ -60,8 +60,6 @@ class Group extends ParanoidModel<
InferAttributes<Group>,
Partial<InferCreationAttributes<Group>>
> {
static eventNamespace = "groups";
@Length({ min: 0, max: 255, msg: "name must be be 255 characters or less" })
@NotContainsUrl
@Column
-2
View File
@@ -20,8 +20,6 @@ class Pin extends IdModel<
InferAttributes<Pin>,
Partial<InferCreationAttributes<Pin>>
> {
static eventNamespace = "pins";
@Length({
max: 256,
msg: `index must be 256 characters or less`,
-2
View File
@@ -83,8 +83,6 @@ class Share extends IdModel<
InferAttributes<Share>,
Partial<InferCreationAttributes<Share>>
> {
static eventNamespace = "shares";
@Column
published: boolean;
-2
View File
@@ -19,8 +19,6 @@ class Star extends IdModel<
InferAttributes<Star>,
Partial<InferCreationAttributes<Star>>
> {
static eventNamespace = "stars";
@Length({
max: 256,
msg: `index must be 256 characters or less`,
-2
View File
@@ -28,8 +28,6 @@ class Subscription extends ParanoidModel<
InferAttributes<Subscription>,
Partial<InferCreationAttributes<Subscription>>
> {
static eventNamespace = "subscriptions";
@BelongsTo(() => User, "userId")
user: User;
+3 -5
View File
@@ -47,8 +47,7 @@ class Model<
TCreationAttributes extends {} = TModelAttributes
> extends SequelizeModel<TModelAttributes, TCreationAttributes> {
/**
* The namespace to use for events, if none is provided an event will not be created
* during the migration period. In the future this may default to the table name.
* The namespace to use for events - defaults to the table name if none is provided.
*/
static eventNamespace: string | undefined;
@@ -219,11 +218,10 @@ class Model<
model: T,
context: HookContext
) {
const namespace = this.eventNamespace;
const namespace = this.eventNamespace ?? this.tableName;
const models = this.sequelize!.models;
// If no namespace is defined, don't create an event
if (!namespace || !context.event?.create) {
if (!context.event?.create) {
return;
}