/
morlli
/
zavav
Обзор
Документация
Войти
/
morlli
/
zavav
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
server/models/Application.js
39 строк
749 B
morlli
34
28 май 2026, 19:48
28 май 2026, 19:48
3299f08
Код
Авторство
О чём код?
const mongoose = require('mongoose'); const applicationSchema = new mongoose.Schema({ userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true }, petId: { type: mongoose.Schema.Types.ObjectId, ref: 'Pet', required: true }, status: { type: String, enum: ['pending', 'approved', 'rejected'], default: 'pending' }, reason: { type: String, required: true }, submittedAt: { type: Date, default: Date.now }, updatedAt: { type: Date, default: Date.now } }); // Update updatedAt before saving applicationSchema.pre('save', function(next) { this.updatedAt = Date.now(); next(); }); module.exports = mongoose.model('Application', applicationSchema);