2016-06-16 22:07:38 +02:00
|
|
|
import mongoose from 'mongoose';
|
|
|
|
const Schema = mongoose.Schema;
|
2016-06-17 22:40:13 +02:00
|
|
|
import shortid from 'shortid';
|
2016-06-16 22:07:38 +02:00
|
|
|
|
2016-06-29 18:52:16 +02:00
|
|
|
const defaultSketch = `setup() {
|
|
|
|
createCanvas(400, 400);
|
|
|
|
}
|
|
|
|
draw() {
|
|
|
|
background(220);
|
|
|
|
}`
|
|
|
|
|
2016-06-17 20:11:52 +02:00
|
|
|
const fileSchema = new Schema({
|
2016-06-24 00:29:55 +02:00
|
|
|
name: { type: String, default: 'sketch.js' },
|
2016-06-29 18:52:16 +02:00
|
|
|
content: { type: String, default: defaultSketch }
|
2016-06-24 00:29:55 +02:00
|
|
|
}, { timestamps: true });
|
2016-06-17 20:11:52 +02:00
|
|
|
|
2016-06-16 22:07:38 +02:00
|
|
|
const projectSchema = new Schema({
|
2016-06-24 00:29:55 +02:00
|
|
|
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 });
|
2016-06-16 22:07:38 +02:00
|
|
|
|
2016-06-24 00:29:55 +02:00
|
|
|
export default mongoose.model('Project', projectSchema);
|