This repository has been archived by the owner on Jan 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
createChampionship Method
Jeremy Fourna edited this page Mar 18, 2016
·
1 revision
Located in lib/collections/championshipsCollection.js
createChampionship(userId, name, publicOrPrivate) {
check(userId, String);
check(name, String);
check(publicOrPrivate, Boolean);
var championshipId = Championships.insert({
name,
players: [{
playerId: userId,
points: [1500]
}],
createdAt: new Date(),
createdBy: userId,
public: publicOrPrivate
});
return championshipId;
}
This method take 3 mandatory parameters : userId, name, publicOrPrivate
check(userId, String);
Verify if the userId
params is a String
. It's the userId that wants to create a new championship.
check(name, String);
Verify if the name
params is a String
. It's the name of the new championship.
check(publicOrPrivate, Boolean);
Verify if the publicOrPrivate
params is a Boolean
. Championship public or private ?
var championshipId = Championships.insert({
name,
players: [{
playerId: userId,
points: [1500]
}],
createdAt: new Date(),
createdBy: userId,
public: publicOrPrivate
});
We initialize the userId
as a player inside the players
Array
with 1500 points. We add the createdAt
with the current date. The userId
is the creator of the championship via the createdBy
property.
- Home
- Championships
- New Championship
- Championship detail
- Game detail
- My Account