Methods
# assertInRole(user, role)
Asserts that the passed user has the specified role.
Parameters:
Name | Type | Description |
---|---|---|
user |
The user (username or userID). |
|
role |
The role or an array of roles. |
If the user does not have the role, or if user or role is not valid.
# define(username, role) → {String}
Define a new user, which means creating an entry in Meteor.Accounts. This is called in the various Profile define() methods.
Parameters:
Name | Type | Description |
---|---|---|
username |
The username to be defined (must be an email address). |
|
role |
The role. |
If the user exists.
The docID of the newly created user.
# filterProfiles(filter) → {Array}
Iterates through all Profile collections, and returns an array of profiles that satisfy filter.
Parameters:
Name | Type | Description |
---|---|---|
filter |
A function that accepts a profile a document and returns truthy if that document should be included in the returned array. |
An array of profile documents from across all the Profile collections satisfying filter.
# findProfileFromUsername(username)
Returns the profile associated with the passed username, or null if not found. Does not check to see if the user is defined, which makes this method useful for Accounts.validateNewUser.
Parameters:
Name | Type | Description |
---|---|---|
username |
A username. |
The profile document, or null if not found.
# findProfiles(selector, options) → {Array}
Runs find on all the Profile collections, fetches the associated documents, and returns an array containing all of the matches.
Parameters:
Name | Type | Description |
---|---|---|
selector |
Object | A MongoDB selector. |
options |
Object | MongoDB options. |
An array of documents matching the selector and options.
# findProfilesWithRole(selector, options) → {Array}
Runs find on all the Profile collections, fetches the associated documents, and returns an array containing all of the matches.
Parameters:
Name | Type | Description |
---|---|---|
selector |
Object | A MongoDB selector. |
options |
Object | MongoDB options. |
An array of documents matching the selector and options.
# getFullName(user) → {string}
Returns the full name for the given user.
Parameters:
Name | Type | Description |
---|---|---|
user |
the user (username or ID). |
If user is not a valid user.
The user's full name.
# getID(user) → {String}
Returns the userID associated with user, or throws an error if not defined.
Parameters:
Name | Type | Description |
---|---|---|
user |
The user (username or userID). |
If user is not a defined username or userID.
The userID
# getIDs(users) → {Array.<String>}
Returns the userIDs associated with users, or throws an error if any cannot be found.
Parameters:
Name | Type | Description |
---|---|---|
users |
Array.<String> | An array of valid users. |
If any instance is not a user.
The docIDs associated with users.
# getInterestIDs(user) → {Array}
Returns the user's interests as IDs. It is a union of interestIDs and careerGoal interestIDs.
Parameters:
Name | Type | Description |
---|---|---|
user |
The username or userID. |
An array of interestIDs.
# getProfile(user) → {Object}
Returns the profile document associated with user.
Parameters:
Name | Type | Description |
---|---|---|
user |
The username or userID. |
If the document was not found.
The profile document.
# getPublicationName() → {String}
Return the publication name.
The publication name, as a string.
# hasProfile(user) → {Object|Null}
Returns the profile document associated with user, or null if not found. Assumes that the user is defined. If not, throws an error.
Parameters:
Name | Type | Description |
---|---|---|
user |
The username or userID. |
The profile document or null if not found.
# isDefined(user) → {boolean}
Returns true if user is a defined userID or username.
Parameters:
Name | Type | Description |
---|---|---|
user |
The user. |
True if user is defined, false otherwise.
# isReferenced(user) → {boolean}
Returns true if user is referenced by other "public" entities. Specifically:
- The user is a faculty member as has sponsored an opportunity. Used to determine if this user can be deleted. Note this doesn't test for references to CourseInstances, etc. These are "private" and will be deleted implicitly if this user is deleted.
Parameters:
Name | Type | Description |
---|---|---|
user |
The username or userID. |
If the username is not defined.
True if this user is referenced "publicly" elsewhere.
# publish()
Publish the username field for all users.
# removeAll()
Removes all users except for the admin user. This is implemented by mapping through all elements because mini-mongo does not implement the remove operation. So this approach can be used on both client and server side. removeAll should only used for testing purposes, so it doesn't need to be efficient.
# someProfiles(predicate) → {boolean}
Returns true if at least one profile satisfies the passed predicate.
Parameters:
Name | Type | Description |
---|---|---|
predicate |
A function which can be applied to any document in any profile collection and returns true or false. |
True if at least one document satisfies the predicate.
# subscribe()
Default subscription method for entities. It subscribes to the entire collection.