@Sergio這就是我現在接觸它的方式。你將如何工作在隨機文件名的功能?謝謝
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var ImageSchema = new Schema({
name: String,
_id:false
})
ImageSchema.virtual('url').get(function() {
var parent = this.parent()
var root = (parent.parent ? parent.parent() : parent)
return root.category + "/" + root.path +"/"+ this.name
});
ImageSchema.set('toJSON', {
virtuals: true
});
var CombinationSchema = new Schema({
name: String,
description: String,
images: [ImageSchema],
_id:false
})
var CasinoSchema = new Schema({
name: String,
category: {
type: String,
default: 'casino'
},
images: [ImageSchema],
path: String,
description: String,
combinations: [CombinationSchema]
})
module.exports = mongoose.model('casinos', CasinoSchema)
你是什麼意思,「維持」?一旦你存儲它,你不需要再次觸摸它。 –
感謝您的反饋。澄清原文中「維護」的含義。 – Seltsam