multy-stub/server/routers/kazan-explore/model/results.js

27 lines
568 B
JavaScript
Raw Normal View History

2025-01-24 22:39:25 +03:00
const { Schema, model } = require('mongoose')
const { KAZAN_EXPLORE_RESULTS_MODEL_NAME } = require('../const')
const schema = new Schema({
userId: { type: String },
items: [
{
quizId: { type: String },
result: { type: Number }
}
]
})
schema.set('toJSON', {
virtuals: true,
versionKey: false,
transform: function (doc, ret) {
delete ret._id
}
})
schema.virtual('id').get(function () {
return this._id.toHexString()
})
exports.ResultsModel = model(KAZAN_EXPLORE_RESULTS_MODEL_NAME, schema)