mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 19:40:11 +08:00
Create session
This commit is contained in:
1 parent
5e8115be11
commit
237d6d5797
2 files changed
+5
-4
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
import Session from '../../models/session.js'
|
import Session from '../../models/session.js'
|
||||||
|
import Quest from '../../models/quest.js'
|
||||||
|
|
||||||
export async function getSessionList(req, res) {
|
export async function getSessionList(req, res) {
|
||||||
try {
|
try {
|
||||||
@@ -10,9 +11,10 @@ export async function getSessionList(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function createSession(req, res) {
|
export async function createSession(req, res) {
|
||||||
|
const quest = await Quest.findOne({ name: req.body.quest_name })
|
||||||
const newSession = new Session({
|
const newSession = new Session({
|
||||||
user: req.user.id,
|
user: req.user,
|
||||||
exercise: req.body.quest_id,
|
quest,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(newSession)
|
console.log(newSession)
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ const Session = model(
|
|||||||
'Session',
|
'Session',
|
||||||
new Schema(
|
new Schema(
|
||||||
{
|
{
|
||||||
name: String,
|
|
||||||
containerId: String,
|
|
||||||
user: {
|
user: {
|
||||||
type: Schema.ObjectId,
|
type: Schema.ObjectId,
|
||||||
ref: 'User',
|
ref: 'User',
|
||||||
@@ -14,6 +12,7 @@ const Session = model(
|
|||||||
type: Schema.ObjectId,
|
type: Schema.ObjectId,
|
||||||
ref: 'Quest',
|
ref: 'Quest',
|
||||||
},
|
},
|
||||||
|
containerId: String,
|
||||||
finishedAt: Date,
|
finishedAt: Date,
|
||||||
terminals: [String],
|
terminals: [String],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user