# new TeamChallengeCollection()
Extends
Methods
# assertDefined(name)
Verifies that the passed object is one of this collection's instances.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | List | Should be a defined ID or doc in this collection. |
If not defined.
# assertValidRoleForMethod(userId)
Checks to see if the user is in the valid role to execute the ValidatedMethods.
Parameters:
Name | Type | Description |
---|---|---|
userId |
String | the user ID. |
# count() → {Number}
Returns the number of documents in this collection.
The number of elements in this collection.
# define(team, challenge) → {String}
Defines a new pair.
Parameters:
Name | Type | Description |
---|---|---|
team |
String | the team slug or ID. |
challenge |
String | the challenge slug or ID. |
the ID of the new pair.
# dumpAll() → {Object}
Returns an object with two fields: name and contents. Name is the name of this collection. Contents is an array of objects suitable for passing to the restore() method.
An object representing the contents of this collection.
# dumpOne(docID) → {Object}
Returns an object representing the definition of docID in a format appropriate to the restoreOne function. Must be overridden by each collection.
Parameters:
Name | Type | Description |
---|---|---|
docID |
String | A docID from this collection. |
An object representing this document.
# find(selector, options) → {Mongo.Cursor}
Runs find on this collection.
Parameters:
Name | Type | Description |
---|---|---|
selector |
Object | A MongoDB selector. |
options |
Object | MongoDB options. |
- Overrides:
- See:
# findDoc(name) → {Object}
A stricter form of findOne, in that it throws an exception if the entity isn't found in the collection.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Object | Either the docID, or an object selector, or the 'name' field value. |
If the document cannot be found.
The document associated with name.
# findOne(selector, options) → {Mongo.Cursor}
Runs findOne on this collection.
Parameters:
Name | Type | Description |
---|---|---|
selector |
Object | A MongoDB selector. |
options |
Object | MongoDB options. |
- Overrides:
- See:
# getCollectionName() → {string}
Returns the collection name.
- Overrides:
The collection name as a string.
# getPublicationName() → {String}
Return the publication name.
- Overrides:
The publication name, as a string.
# isDefined(name) → {boolean}
Returns true if the passed entity is in this collection.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | Object | The docID, or an object specifying a documennt. |
True if name exists in this collection.
# publish()
Default publication method for entities. It publishes the entire collection. This should be overridden in subclasses.
# removeChallenge(challenge)
Removes all the pairs with the given challenge.
Parameters:
Name | Type | Description |
---|---|---|
challenge |
String | challenge slug or ID. |
# removeIt(docID)
Removes the pair.
Parameters:
Name | Type | Description |
---|---|---|
docID |
String | the ID of the pair. |
# removeTeam(team)
Removes all the pairs with the given team.
Parameters:
Name | Type | Description |
---|---|---|
team |
String | the team slug or ID. |
# restoreAll(dumpObjects)
Defines all the entities in the passed array of objects.
Parameters:
Name | Type | Description |
---|---|---|
dumpObjects |
The array of objects representing the definition of a document in this collection. |
# restoreOne(dumpObject) → {String}
Defines the entity represented by dumpObject. Defaults to calling the define() method if it exists.
Parameters:
Name | Type | Description |
---|---|---|
dumpObject |
An object representing one document in this collection. |
The docID of the newly created document.
# subscribe()
Default subscription method for entities. It subscribes to the entire collection. Should be overridden in subclass
# update(docID, team, challenge)
Updates the given team-challenge pair.
Parameters:
Name | Type | Description |
---|---|---|
docID |
String | the ID of the pair. |
team |
String | the slug or ID of the new team (optional). |
challenge |
String | the slug or ID of the new challenge (optional). |
if docID is not defined.