mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
backend: route save / restore
This commit is contained in:
parent
032821329b
commit
d932fcb287
17 changed files with 163 additions and 43 deletions
22
backend/models/Route.js
Normal file
22
backend/models/Route.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const mongoose = require('mongoose');
|
||||
|
||||
const { Schema } = mongoose;
|
||||
|
||||
const RouteSchema = new Schema(
|
||||
{
|
||||
_id: { type: String, required: true },
|
||||
title: { type: String, default: '' },
|
||||
// address: { type: String, required: true },
|
||||
version: { type: Number, default: 2 },
|
||||
route: { type: Array },
|
||||
stickers: { type: Array },
|
||||
owner: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
logo: { type: String, default: 'DEFAULT' },
|
||||
distance: { type: Number, default: 0 },
|
||||
},
|
||||
{
|
||||
timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' }
|
||||
}
|
||||
);
|
||||
|
||||
module.exports.RouteSchema = RouteSchema;
|
|
@ -17,11 +17,11 @@ const UserSchema = new Schema(
|
|||
first_name: { type: String },
|
||||
last_name: { type: String },
|
||||
photo: { type: String },
|
||||
routes: [{ type: Schema.Types.ObjectId, ref: 'Route' }]
|
||||
},
|
||||
{
|
||||
timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' }
|
||||
}
|
||||
);
|
||||
|
||||
const User = mongoose.model('User', UserSchema);
|
||||
module.exports.User = User;
|
||||
module.exports.UserSchema = UserSchema;
|
||||
|
|
8
backend/models/index.js
Normal file
8
backend/models/index.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
const mongoose = require('mongoose');
|
||||
|
||||
const { UserSchema } = require('./User');
|
||||
const { RouteSchema } = require('./Route');
|
||||
|
||||
module.exports.User = mongoose.model('User', UserSchema);
|
||||
module.exports.Route = mongoose.model('Route', RouteSchema);
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue