From 830b0fdf84dcc309b6073a8cde95436ed1d5ee3b Mon Sep 17 00:00:00 2001 From: boutmoun123 Date: Sun, 5 Jul 2026 14:57:22 +0300 Subject: [PATCH] Fix shared post schema startup crash --- .../posts/schemas/post-share.schema.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/modules/posts/schemas/post-share.schema.ts b/src/modules/posts/schemas/post-share.schema.ts index 4517eba..76628dd 100644 --- a/src/modules/posts/schemas/post-share.schema.ts +++ b/src/modules/posts/schemas/post-share.schema.ts @@ -1,15 +1,9 @@ -import { Prop, Schema, SchemaFactory, raw } from '@nestjs/mongoose'; -import { HydratedDocument, Types } from 'mongoose'; +import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; +import { HydratedDocument, SchemaTypes, Types } from 'mongoose'; import { PostShareTarget } from '../dto/share-post.dto'; export type PostShareDocument = HydratedDocument; -export const sharedFromSchema = raw({ - type: { type: String, enum: ['user', 'profile', 'feed', 'unknown'], default: 'unknown' }, - id: { type: String, default: '' }, - name: { type: String, default: '' }, -}); - @Schema({ timestamps: true, versionKey: false, collection: 'postshares' }) export class PostShare { @Prop({ type: Types.ObjectId, required: true, index: true }) @@ -21,8 +15,14 @@ export class PostShare { @Prop({ type: Types.ObjectId, required: true, index: true }) originalAuthorId!: Types.ObjectId; - @Prop({ type: sharedFromSchema, default: null }) - sharedFrom?: { type: 'user' | 'profile' | 'feed' | 'unknown'; id?: string; name?: string } | null; + @Prop({ type: SchemaTypes.Mixed, default: undefined }) + sharedFrom?: { + type: 'user' | 'profile' | 'feed' | 'unknown'; + id?: string; + name?: string; + username?: string; + avatar?: string; + }; @Prop({ type: String, enum: Object.values(PostShareTarget), default: PostShareTarget.PROFILE, index: true }) target!: PostShareTarget;