for the node+mongoose project I wrote, the code that defines the mongoose module is stored in the models folder. If I write a module.exports= export, node will report an error.
here is a model
const mongoose = require("mongoose")
const Schema = mongoose.Schema
const mongoosePaginate = require("mongoose-paginate")
//
/**
*fieldType:
(input)text
textarea
(input)number
(input)email
(input)date
(input)radio
(input)checkbox
select
table
(input)file(url)
*/
const FormModelSchema = new Schema({
formName: String,
instruction: String,
userName: String,
updateUserName: String,
userId:String,
updateUserId: String,
createAt: {type: Date, default: Date.now},
updateAt: {type: Date, default: Date.now},
formFields: [{
displayName: String,
// fieldName:String,
fieldType: String,
placeholder:String,
isRequired:{type: Boolean, default: false},
value:String,
column:String,
fieldOptions:[{
displayText:String,
}],
fieldOrder:Number
// or /
// maxSize:String,
}]
})
// Defines a pre hook for the document.
FormModelSchema.pre("save", function(next) {
if (this.isNew) {
this.createAt = this. updateAt = Date.now()
}
else {
this.updateAt = Date.now()
}
next()
})
FormModelSchema.plugin(mongoosePaginate)
var FormModel=mongoose.model("FormModel", FormModelSchema)
module.exports=FormModel
this is an error message:
app.jsrequire modelsjs
:
modelformModel
model:
: