model helper module
This module contains helper functions for interacting with models
- Source:
Methods
(static) module.exports.getMember(q) → {Object}
export one or more members
When none of _id, memberID, or councilID are specified,
this function will return an ARRAY of all members in the database. If
there are no members in the database, an empty array will be returned.
This feature should be used sparingly, it is very inefficient and can
crash the server once more users are loaded.
When q._id contains a value, a SINGLE member will be returned matching that _id.
If no member is found with that _id, undef will be returned.
If q._id is not specified, but both q.memberID and q.councilID are specified,
a SINGLE member will be returned matching both that memberID and councilID.
If no member is found with that memberID and councilID, undef will be returned.
DEPRECATED BEHAVIOR: If q.memberID is specified and q.councilID is not specified,
a SINGLE member will be returned matching that memberID. It is possible for
two members in different councils to have the same memberID. If this happens
and more than one member is found, the first record found will be returned.
If no member is found with that memberID, undef will be returned.
By default (or when q.return="simple"), a simplified JavaScript object will
be returned where BigInt and Date values are converted to strings. This
loses all of the usual capabilities of a model but is easier to pass into
a template. To return a fully-capable model instead, specify q.return="model".
When q.return="strict", the result is the same as "simple" with the extra
caveat that only fields that actually exist in the database will be returned.
If q.return contains anything other than "model" or "simple" or "strict", undef will
be returned.
If q is passed something other than an object, undef will be returned.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
q |
Object | query parameters
Properties
|
- Source:
Returns:
or {Array} see description above
- Type
- Object
(static) module.exports.getRegistration(q) → {Object}
export one or more registrations
When none of _id, memberID, or councilID are specified,
this function will return an ARRAY of all registrations in the database. If
there are no registrations in the database, an empty array will be returned.
This feature should be used sparingly, it is very inefficient and can
crash the server once more registrations are loaded.
When q._id contains a value, a SINGLE registration will be returned matching that _id.
If no registration is found with that _id, undef will be returned. This is NOT a
search of registrations matching that member._id! This is the unique ID of the
registration itself.
When q._id is not specified, but q.member_id is specified, an array of registrations
will be returned for the member with that _id. If no registrations are found is found
with that _id, undef will be returned. (This performs a lookup on the backend and
internally translates the request to one that specifies a user by memberID and
councilID, which is an inefficient way to perform this lookup - but matches the
data schema.)
If q._id and member_id are not specified, but both q.memberID and q.councilID
are specified, an array of registrations will be returned for the member with that
memberID and councilID. If no registrations are found is found with that
memberID and councilID, undef will be returned.
If not looking up by _id and q.earliest is specified, only entries at or after that
date will be returned.
By default (or when q.return="simple"), a simplified JavaScript object will
be returned where BigInt and Date values are converted to strings. This
loses all of the usual capabilities of a model but is easier to pass into
a template. To return a fully-capable model instead, specify q.return="model".
If q.return contains anything other than "model" or "simple", undef will
be returned.
If q is passed something other than an object, undef will be returned.
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
q |
Object | query parameters
Properties
|
- Source:
Returns:
or {Array} see description above
- Type
- Object