Namespace: Review

Review

Model for reviews, including the full text.

Source:

Methods

(async, static) create(reviewObj, optionsopt) → {Review}

Create and save a review and the associated Thing and Teams. If there is no Thing record, this function creates and saves one via Review.findOrCreateThing.

Parameters:
Name Type Attributes Description
reviewObj Object

object containing the data to associate with this review, as defined in Review schema.

options Object <optional>

options for the created revision

Properties
Name Type Description
tags Array.<String>

tags to associate with this revision

files Array.<String>

UUIDs of files to add to the Thing for this review

Source:
Returns:

the saved review

Type
Review

(async, static) findOrCreateThing(reviewObj) → {Thing}

Locate the review subject (Thing) for a new review, or create and save a new Thing based on the provided URL. This will also perform adapter lookups for external metadata (e.g., from Wikidata).

This function is called from Review.create.

Parameters:
Name Type Description
reviewObj Object

the data associated with the review we're locating or creating a Thing record for

Source:
Returns:

the located or created Thing

Type
Thing

(async, static) getFeed(optionsopt) → {Array.<Review>}

Get an ordered array of reviews, optionally filtered by user, date, review subject, and other criteria.

Parameters:
Name Type Attributes Description
options Object <optional>

Feed selection criteria

Properties
Name Type Default Description
createdBy User

author to filter by

offsetDate Date

get reviews older than this date

onlyTrusted Boolean false

only get reviews by users whose user.isTrusted is truthy. Is applied after the limit, so you may end up with fewer reviews than specified.

thingID String

only get reviews of the Thing with the provided ID

withThing Boolean true

join the associated Thing object with each review

withTeams Boolean true

join the associated Team objects with each review

withoutCreator String

exclude reviews by the user with the provided ID

limit Number 10

how many reviews to load

Source:
Returns:

the reviews matching the provided criteria

Type
Array.<Review>

(async, static) getWithData(id) → {Review}

Get a review by ID, including commonly joined data: the review subject (thing), the user who created the review, and the teams with which it was associated. WARNING: since the password is filtered out, any future calls to saveAll() must be explicitly parametrized to not include the user, or the save will throw an error.

Parameters:
Name Type Description
id String

the unique ID to look up

Source:
Returns:

the review and associated data

Type
Review

(static) validateSocialImage(optionsopt)

Ensure that the social media image specified for this review is associated already with the review subject, or in the list of newly uploaded files. Throws a ReviewError if not.

Parameters:
Name Type Attributes Description
options Object <optional>

Validation data

Properties
Name Type Description
socialImageID String

Social media image UUID

newFileIDs Array.<String>

Array of newly uploaded file IDs

fileObjects Array.<File>

Array of previously uploaded file objects associated with review subject

Source:

deleteAllRevisionsWithThing(user) → {Promise}

Delete all revisions of a review including the associated review subject (thing).

Parameters:
Name Type Description
user User

user initiating the action

Source:
Returns:

promise that resolves when all content has been deleted

Type
Promise

populateUserInfo(user)

Populate virtual fields with permissions for a given user

Parameters:
Name Type Description
user User

the user whose permissions to check

Source: