Refactor relationship types to single class and add more

Took 38 minutes
This commit is contained in:
2025-04-16 15:39:13 +02:00
parent 0333d37aae
commit c31b5c5b14
6 changed files with 48 additions and 41 deletions

View File

@ -1,5 +1,10 @@
import mongoose, { Document, Schema } from 'mongoose';
export const RELATIONSHIP_TYPES = [
'acquaintance', 'friend', 'partner', 'family', 'secondDegree', 'colleague', 'teacher', 'exPartner', 'custom',
];
export interface IRelationship extends Document {
_id: string;
source: mongoose.Types.ObjectId;
@ -24,7 +29,7 @@ const RelationshipSchema = new Schema(
type: {
type: String,
required: [true, 'Relationship type is required'],
enum: ['freund', 'partner', 'familie', 'arbeitskolleg', 'custom'],
enum: RELATIONSHIP_TYPES,
},
customType: {
type: String,
@ -36,7 +41,7 @@ const RelationshipSchema = new Schema(
required: true,
},
},
{ timestamps: true }
{ timestamps: true },
);
// Create compound index to ensure unique relationships in a network