17 lines
449 B
JavaScript
17 lines
449 B
JavaScript
import mongoose from "mongoose";
|
|
|
|
const materialSchema = new mongoose.Schema({
|
|
name: { required: true, type: String },
|
|
url: { required: false, type: String },
|
|
image: { required: false, type: Buffer },
|
|
tags: [{ type: String }],
|
|
});
|
|
|
|
materialSchema.virtual("id").get(function () {
|
|
return this._id.toHexString();
|
|
});
|
|
|
|
materialSchema.set("toJSON", { virtuals: true });
|
|
|
|
export const materialModel = mongoose.model("Material", materialSchema);
|