33 lines
No EOL
1 KiB
JavaScript
33 lines
No EOL
1 KiB
JavaScript
// server/models/member.js
|
|
import mongoose from 'mongoose'
|
|
import { resolve } from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
|
|
// Import configs using dynamic imports to avoid build issues
|
|
const getValidCircleValues = () => ['community', 'founder', 'practitioner']
|
|
const getValidContributionValues = () => ['0', '5', '15', '30', '50']
|
|
|
|
const memberSchema = new mongoose.Schema({
|
|
email: { type: String, required: true, unique: true },
|
|
name: { type: String, required: true },
|
|
circle: {
|
|
type: String,
|
|
enum: getValidCircleValues(),
|
|
required: true
|
|
},
|
|
contributionTier: {
|
|
type: String,
|
|
enum: getValidContributionValues(),
|
|
required: true
|
|
},
|
|
helcimCustomerId: String,
|
|
helcimSubscriptionId: String,
|
|
slackInvited: { type: Boolean, default: false },
|
|
createdAt: { type: Date, default: Date.now },
|
|
lastLogin: Date
|
|
})
|
|
|
|
// Check if model already exists to prevent re-compilation in development
|
|
export default mongoose.models.Member || mongoose.model('Member', memberSchema) |