@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