
I am attempting to create 12 documents in my games collection I am successfully able to create 5 and then there is a server error on 6 it will create 5 more and a server erron on 12.
Is there a way to make this create all 12 games?

this is the terminal output Game 1 created successfully. Game 2 created successfully. Game 3 created successfully. Game 4 created successfully. Game 5 created successfully. Error creating game 6: AppwriteException: Server Error
119 | if (gameData) { 120 | try {
121 | await databases.createDocument( | ^ 122 | process.env.NEXT_PUBLIC_APPWRITE_DATABASE!, 123 | process.env.NEXT_PUBLIC_APPWRITE_COLLECTION_LEAGUE_GAMES!, 124 | ID.unique(), { code: 500, type: 'general_unknown', response: [Object] } Game 7 created successfully. Game 8 created successfully. Game 9 created successfully. Game 10 created successfully. Game 11 created successfully. Error creating game 12: AppwriteException: Server Error

and this is the code we are using to process the createDocument
for (let gameNumber = 1; gameNumber <= 12; gameNumber++) {
const gameData = createGameData(
gameNumber,
newMatchup.$id,
team1Players,
team2Players
);
if (gameData) {
try {
await databases.createDocument(
process.env.NEXT_PUBLIC_APPWRITE_DATABASE!,
process.env.NEXT_PUBLIC_APPWRITE_COLLECTION_LEAGUE_GAMES!,
ID.unique(),
gameData
);
console.log(Game ${gameNumber} created successfully.
);
} catch (error) {
console.error(Error creating game ${gameNumber}:
, error);
// Handle the error, perhaps skip this game or try again later
}
}
}
return { success: true, matchup: newMatchup };
} catch (error) { console.error("Error creating league matchup or games:", error); return { error: "Failed to create matchup or games. Please try again.", }; } }
// Helper function to create game data based on game number function createGameData( gameNumber: number, matchupId: string, team1Players: string[], team2Players: string[] ) { const gameStructure = { 1: { team1: [0, 2], team2: [0, 2] }, 2: { team1: [1, 3], team2: [1, 3] }, 3: { team1: [0, 3], team2: [0, 3] }, 4: { team1: [1, 2], team2: [1, 2] }, 5: { team1: [0, 1], team2: [2, 3] }, 6: { team1: [2, 3], team2: [0, 1] }, 7: { team1: [0, 2], team2: [1, 3] }, 8: { team1: [1, 3], team2: [0, 2] }, 9: { team1: [0, 3], team2: [1, 2] }, 10: { team1: [1, 2], team2: [0, 3] }, 11: { team1: [0, 1], team2: [0, 1] }, 12: { team1: [2, 3], team2: [2, 3] }, };
const { team1, team2 } = gameStructure[gameNumber]; return { matchupId: matchupId, team1: [team1Players[team1[0]], team1Players[team1[1]]], team2: [team2Players[team2[0]], team2Players[team2[1]]], }; }
Recommended threads
- Upgrading Appwrite 1.7.4 → 1.8.x: What H...
I'm currently running a self-hosted Appwrite v1.7.4 instance that still uses the old Collections/Documents database model. I noticed that starting from v1.8.x,...
- File tokens regenerate each page reload
Hello, on appwrite 1.7.4, when I create a file token via the API Tokens(appwriteAdminClient)#createFileToken I get a secret, then when I check in the console t...
- CSV Import Shows Success but Data Not Ap...
I tried importing a CSV file into my PRODUCTS collection. The dashboard shows the message “Import to PRODUCTS completed successfully,” but no data appears in th...
