Class

UserCollection

api/user.UserCollection()

Represents a user, which is someone who has a Meteor account.

Users are defined when the various Profile collections are initialized, so the User collection is the union of Students, Faculty and Advisors, plus the single Admin account who also has a Meteor account.

Note that this collection does not extend any of our Base collections, because it has a very limited API which should be used by clients to access the various Profile collections.

It is not saved out or restored when the DB is dumped. It is not listed in RadGrad.collections.

Clients provide a "user" as a parameter, which is either the username (i.e. email) or userID.

Constructor

# new UserCollection()

View Source api/user/UserCollection.ts, line 28

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.

View Source api/user/UserCollection.ts, line 116

If the user does not have the role, or if user or role is not valid.

Meteor.Error

# 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.

View Source api/user/UserCollection.ts, line 55

If the user exists.

Meteor.Error

The docID of the newly created user.

String

# 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.

View Source api/user/UserCollection.ts, line 373

An array of profile documents from across all the Profile collections satisfying filter.

Array

# 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.

View Source api/user/UserCollection.ts, line 233

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.

See:

View Source api/user/UserCollection.ts, line 329

An array of documents matching the selector and options.

Array

# 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.

See:

View Source api/user/UserCollection.ts, line 345

An array of documents matching the selector and options.

Array

# getFullName(user) → {string}

Returns the full name for the given user.

Parameters:
Name Type Description
user

the user (username or ID).

View Source api/user/UserCollection.ts, line 173

If user is not a valid user.

Meteor.Error

The user's full name.

string

# 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).

View Source api/user/UserCollection.ts, line 144

If user is not a defined username or userID.

Meteor.Error

The userID

String

# 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.

View Source api/user/UserCollection.ts, line 157

If any instance is not a user.

Meteor.Error

The docIDs associated with users.

Array.<String>

# 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.

View Source api/user/UserCollection.ts, line 432

An array of interestIDs.

Array

# getProfile(user) → {Object}

Returns the profile document associated with user.

Parameters:
Name Type Description
user

The username or userID.

View Source api/user/UserCollection.ts, line 282

If the document was not found.

Meteor.Error

The profile document.

Object

# getPublicationName() → {String}

Return the publication name.

View Source api/user/UserCollection.ts, line 470

The publication name, as a string.

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.

View Source api/user/UserCollection.ts, line 206

The profile document or null if not found.

Object | Null

# isDefined(user) → {boolean}

Returns true if user is a defined userID or username.

Parameters:
Name Type Description
user

The user.

View Source api/user/UserCollection.ts, line 134

True if user is defined, false otherwise.

boolean

# 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.

View Source api/user/UserCollection.ts, line 195

If the username is not defined.

Meteor.Error

True if this user is referenced "publicly" elsewhere.

boolean

# publish()

Publish the username field for all users.

View Source api/user/UserCollection.ts, line 444

# 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.

View Source api/user/UserCollection.ts, line 313

# removeIt()

DO NOT USE.

View Source api/user/UserCollection.ts, line 298

Should not be used. Should remove the profile for the user.

Meteor.Error

# 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.

View Source api/user/UserCollection.ts, line 398

True if at least one document satisfies the predicate.

boolean

# subscribe()

Default subscription method for entities. It subscribes to the entire collection.

View Source api/user/UserCollection.ts, line 459