Files
Verso/services/web/app/src/models/Survey.js
T
Eric Mc Sween 65976cb363 Merge pull request #11869 from overleaf/em-upgrade-mongoose-web
Upgrade Mongoose and the Mongo driver in web

GitOrigin-RevId: 2cad1aabe57eae424a9e4c68b2e0062f0e78ffaf
2023-03-01 09:03:27 +00:00

51 lines
983 B
JavaScript

const mongoose = require('../infrastructure/Mongoose')
const { Schema } = mongoose
const MIN_NAME_LENGTH = 3
const MAX_NAME_LENGTH = 200
const NAME_REGEX = /^[a-z0-9-]+$/
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}`,
},
},
preText: {
type: String,
required: true,
},
linkText: {
type: String,
required: true,
},
url: {
type: String,
required: true,
},
options: {
hasRecurlyGroupSubscription: {
type: Boolean,
default: false,
},
},
},
{
collection: 'surveys',
minimize: false,
}
)
module.exports = {
Survey: mongoose.model('Survey', SurveySchema),
SurveySchema,
}