[web] last infrastructure conversions GitOrigin-RevId: ad1aff9b7df0610ed0303157d9e2c8032f32c02b
66 lines
1.3 KiB
JavaScript
66 lines
1.3 KiB
JavaScript
import mongoose from '../infrastructure/Mongoose.mjs'
|
|
const { Schema } = mongoose
|
|
|
|
const MIN_NAME_LENGTH = 3
|
|
const MAX_NAME_LENGTH = 200
|
|
const NAME_REGEX = /^[a-z0-9-]+$/
|
|
|
|
export const SurveySchema = new Schema(
|
|
{
|
|
name: {
|
|
type: String,
|
|
minLength: MIN_NAME_LENGTH,
|
|
maxlength: MAX_NAME_LENGTH,
|
|
required: true,
|
|
validate: {
|
|
validator: function (input) {
|
|
return input !== null && NAME_REGEX.test(input)
|
|
},
|
|
message: `invalid, must match: ${NAME_REGEX}`,
|
|
},
|
|
},
|
|
title: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
text: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
cta: {
|
|
type: String,
|
|
required: false,
|
|
},
|
|
url: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
options: {
|
|
hasRecurlyGroupSubscription: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
earliestSignupDate: {
|
|
type: Date,
|
|
},
|
|
latestSignupDate: {
|
|
type: Date,
|
|
},
|
|
rolloutPercentage: {
|
|
type: Number,
|
|
default: 100,
|
|
},
|
|
excludeLabsUsers: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
collection: 'surveys',
|
|
minimize: false,
|
|
}
|
|
)
|
|
|
|
export const Survey = mongoose.model('Survey', SurveySchema)
|