Is it possible to add more fields to participant? #142
Answered
by
Drarig29
zestsystem
asked this question in
Q&A
-
Currently participant in a tournament just has id, tournament_id, and name. Is it possible to extend the participant model to store extra information such as username, image url, nationality, etc. ? |
Beta Was this translation helpful? Give feedback.
Answered by
Drarig29
Jul 15, 2022
Replies: 1 comment 4 replies
-
Hi! Sorry for the delay... For this, what you should do is insert participants yourself, and then use their Example: import { BracketsManager } from 'brackets-manager';
import { JsonDatabase } from 'brackets-json-db';
const storage = new JsonDatabase();
const manager = new BracketsManager(storage);
const tournamentId = 1;
const participants = [
{ tournament_id: tournamentId, name: 'John', nationality: 'english', imageUrl: 'https://example.org/image.png' },
{ tournament_id: tournamentId, name: 'Nicolas', nationality: 'french', imageUrl: 'https://example.org/image.png' },
{ tournament_id: tournamentId, name: 'Alberto', nationality: 'italian', imageUrl: 'https://example.org/image.png' },
{ tournament_id: tournamentId, name: 'Luis', nationality: 'spanish', imageUrl: 'https://example.org/image.png' },
]
await storage.insert('participant', participants)
const inserted = await storage.select('participant')
await manager.create({
tournamentId: tournamentId,
name: 'My tournament',
type: 'single_elimination',
seeding: inserted.map(p => p.id),
}) |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
Drarig29
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! Sorry for the delay...
For this, what you should do is insert participants yourself, and then use their
id
in the seeding.Example: