feat: add Tag, TagSuggestion, Connection models and extend Member schema

Adds three new Mongoose models for the community connections feature. Extends
Member with craftTags, communityConnections block, privacy fields for both,
and a connectionRequests notification preference.
This commit is contained in:
Jennie Robinson Faber 2026-04-05 16:06:03 +01:00
parent 4aacb26c4b
commit 8112e5ea47
4 changed files with 72 additions and 0 deletions

View file

@ -0,0 +1,22 @@
import mongoose from 'mongoose'
const connectionSchema = new mongoose.Schema({
initiator: { type: mongoose.Schema.Types.ObjectId, ref: 'Member', required: true },
recipient: { type: mongoose.Schema.Types.ObjectId, ref: 'Member', required: true },
status: { type: String, enum: ['pending', 'confirmed'], default: 'pending' },
matchingTags: [
{
tagSlug: String,
initiatorState: String,
recipientState: String,
},
],
hiddenBy: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Member' }],
createdAt: { type: Date, default: Date.now },
confirmedAt: Date,
})
connectionSchema.index({ initiator: 1, recipient: 1 }, { unique: true })
connectionSchema.index({ recipient: 1, status: 1 })
export default mongoose.models.Connection || mongoose.model('Connection', connectionSchema)