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:
parent
4aacb26c4b
commit
8112e5ea47
4 changed files with 72 additions and 0 deletions
22
server/models/connection.js
Normal file
22
server/models/connection.js
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue