p5.js-web-editor/server/models/project.js
2016-06-23 18:29:55 -04:00

17 lines
553 B
JavaScript

import mongoose from 'mongoose';
const Schema = mongoose.Schema;
import shortid from 'shortid';
const fileSchema = new Schema({
name: { type: String, default: 'sketch.js' },
content: { type: String }
}, { timestamps: true });
const projectSchema = new Schema({
name: { type: String, default: "Hello p5.js, it's the server" },
user: { type: Schema.Types.ObjectId, ref: 'User' },
file: { type: fileSchema },
_id: { type: String, default: shortid.generate }
}, { timestamps: true });
export default mongoose.model('Project', projectSchema);