galleryApi
parent
0381f74f06
commit
554b4e8946
|
@ -14,14 +14,27 @@ async function main() {
|
||||||
const collection = database.collection('gameData'); // Replace with your collection name
|
const collection = database.collection('gameData'); // Replace with your collection name
|
||||||
|
|
||||||
// Find a single document
|
// Find a single document
|
||||||
const user = await collection.findOne({ userId: 'dsfdfgffgfgeg' });
|
// const user = await collection.findOne({ userId: 'dsfdfgffgfgeg' });
|
||||||
|
|
||||||
|
const { userId, gameName, gameID } = req.body;
|
||||||
|
const gameData = await collection.findOne({
|
||||||
|
userId: userId,
|
||||||
|
gameName: gameName,
|
||||||
|
gameID: gameID
|
||||||
|
});
|
||||||
|
|
||||||
|
if (gameData) {
|
||||||
|
res.json({gameData});
|
||||||
|
} else {
|
||||||
|
res.status(404).json({ message: 'Game data not found' });
|
||||||
|
}
|
||||||
|
|
||||||
// Output the result
|
// Output the result
|
||||||
if (user) {
|
// if (user) {
|
||||||
console.log('User found:', user);
|
// console.log('User found:', user);
|
||||||
} else {
|
// } else {
|
||||||
console.log('No user found with the username "john_doe"');
|
// console.log('No user found with the username "john_doe"');
|
||||||
}
|
// }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error connecting to MongoDB or performing query:', error);
|
console.error('Error connecting to MongoDB or performing query:', error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue