31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
const mongoose = require('mongoose');
|
|
const Schema = mongoose.Schema;
|
|
|
|
const MapSchema = new Schema({
|
|
name: { type: String, required: true, trim: true },
|
|
// Uploaded image, served from /api/public/<filename>
|
|
image: { type: String, default: '' },
|
|
// Grid cell size in image pixels
|
|
gridSize: { type: Number, min: 1, default: 50 },
|
|
// Grid origin, in image pixels from the top left corner of the image
|
|
offsetX: { type: Number, default: 0 },
|
|
offsetY: { type: Number, default: 0 },
|
|
// Distance each grid cell stands for (feet, metres...)
|
|
scale: { type: Number, min: 0.01, default: 5 },
|
|
// Notes pinned onto the map like markers. x/y are image pixels from the top left corner of the
|
|
// image, so a pin keeps its place whatever the zoom or the grid settings are.
|
|
pins: [{
|
|
note: { type: Schema.Types.ObjectId, ref: 'Note', required: true },
|
|
x: { type: Number, default: 0 },
|
|
y: { type: Number, default: 0 }
|
|
}],
|
|
campaign: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'Campaign',
|
|
required: true
|
|
},
|
|
date: { type: Date, default: Date.now }
|
|
});
|
|
|
|
module.exports = mongoose.model('Map', MapSchema);
|