mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
feat: separate db models from server
This commit is contained in:
1 parent
784ae29ed0
commit
50bf514805
23 files changed
+90
-31
No files matched your search
@@ -0,0 +1,71 @@
|
||||
import { model, Schema } from 'mongoose'
|
||||
|
||||
const responseSchema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
content: [String],
|
||||
speaker: String,
|
||||
color: String,
|
||||
})
|
||||
|
||||
const stageSchema = new Schema({
|
||||
id: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
task: {
|
||||
type: String,
|
||||
},
|
||||
requirements: [
|
||||
{
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
repeatable: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
default: false,
|
||||
},
|
||||
condition: {
|
||||
command: [String],
|
||||
output: [String],
|
||||
error: [String],
|
||||
pwd: [String],
|
||||
},
|
||||
responses: {
|
||||
type: [responseSchema],
|
||||
required: true,
|
||||
},
|
||||
hints: {
|
||||
type: [String],
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const Quest = model(
|
||||
'Quest',
|
||||
new Schema({
|
||||
_id: String,
|
||||
title: String,
|
||||
order: Number,
|
||||
instruction: String,
|
||||
tasks: {
|
||||
id: String,
|
||||
content: String,
|
||||
display: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
completed: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
stages: [stageSchema],
|
||||
})
|
||||
)
|
||||
|
||||
export default Quest
|
||||
Reference in new issue
Block a user