all userId replace to childId #15
|
@ -2,7 +2,7 @@ const mongoose = require("mongoose");
|
|||
|
||||
const gameSchema = new mongoose.Schema({
|
||||
gameName: { type: String, required: true },
|
||||
userId: { type: String, required: true },
|
||||
childId: { type: String, required: true },
|
||||
gameID: { type: String, required: true },
|
||||
gameTime: { type: String, required: false },
|
||||
score: { type: String },
|
||||
|
|
|
@ -2,7 +2,7 @@ const mongoose = require('mongoose');
|
|||
|
||||
// Define the GalleryImage schema
|
||||
const galleryImageSchema = new mongoose.Schema({
|
||||
userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true }, // Assuming you have a User model
|
||||
childId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true }, // Assuming you have a User model
|
||||
gameName: { type: String, required: true },
|
||||
gameID: { type: String, required: true },
|
||||
screenshotUrl: { type: String, required: true },
|
||||
|
|
|
@ -2,7 +2,7 @@ const mongoose = require("mongoose");
|
|||
|
||||
const galleryImageScema = new mongoose.Schema({
|
||||
gameName: { type: String, required: true },
|
||||
userId: { type: String, required: true },
|
||||
childId: { type: String, required: true },
|
||||
gameID: { type: String, required: true },
|
||||
screenshotUrl: { type: String },
|
||||
});
|
||||
|
|
|
@ -15,11 +15,11 @@ async function main() {
|
|||
const collection = database.collection('gameData'); // Replace with your collection name
|
||||
|
||||
// Find a single document
|
||||
// const user = await collection.findOne({ userId: 'dsfdfgffgfgeg' });
|
||||
// const user = await collection.findOne({ childId: 'dsfdfgffgfgeg' });
|
||||
|
||||
const { userId, gameName, gameID } = req.body;
|
||||
const { childId, gameName, gameID } = req.body;
|
||||
const gameData = await collection.findOne({
|
||||
userId: userId,
|
||||
childId: childId,
|
||||
gameName: gameName,
|
||||
gameID: gameID
|
||||
});
|
||||
|
|
|
@ -22,16 +22,16 @@ mongoose.connect(mongoURI, {
|
|||
.catch((err) => console.error("MongoDB connection error:", err));
|
||||
|
||||
const saveGameScore2 = async (req, res) => {
|
||||
const { userId, gameName, gameID, gameTime, score, gameStar, screenShot } = req.body;
|
||||
const { childId, gameName, gameID, gameTime, score, gameStar, screenShot } = req.body;
|
||||
|
||||
try {
|
||||
if (!gameName || !userId || !gameID) {
|
||||
if (!gameName || !childId || !gameID) {
|
||||
return res.status(400).json({ error: "Missing required fields" });
|
||||
}
|
||||
|
||||
const newGame = new Game({
|
||||
gameName,
|
||||
userId,
|
||||
childId,
|
||||
gameID,
|
||||
gameTime,
|
||||
score,
|
||||
|
|
Loading…
Reference in New Issue