All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good
- Introduced a new optional field `hasThumbnails` in the file schema to indicate the presence of thumbnail images. - Set the default value of `hasThumbnails` to false for improved data management.
26 lines
767 B
JavaScript
26 lines
767 B
JavaScript
import mongoose from 'mongoose';
|
|
import { generateId } from '../../utils.js';
|
|
|
|
const fileSchema = new mongoose.Schema(
|
|
{
|
|
_reference: { type: String, default: () => generateId()() },
|
|
name: { required: true, type: String },
|
|
type: { required: true, type: String },
|
|
extension: { required: true, type: String },
|
|
size: { required: false, type: Number },
|
|
metaData: { required: false, type: Object },
|
|
hasThumbnails: { required: false, type: Boolean, default: false },
|
|
},
|
|
{ timestamps: true }
|
|
);
|
|
|
|
fileSchema.index({ name: 'text', type: 'text', extension: 'text' });
|
|
|
|
fileSchema.virtual('id').get(function () {
|
|
return this._id;
|
|
});
|
|
|
|
fileSchema.set('toJSON', { virtuals: true });
|
|
|
|
export const fileModel = mongoose.model('file', fileSchema);
|