Constructor
# new module:Expand(user, authorizedExpands) → {Expand}
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
user |
module:LoggedUser
|
null | |
authorizedExpands |
Array.<string>
|
null |
Expand
Example
const expander = new Expand();
expander.setAuthorized(["books", "editors", "awards"]).process(["books", "editors<current>", "awards~"], expand => {
const isRequired = expand.required ? "required" : "not required";
const hasExtra = expand.how ? ` and have an extra filter (${expand.how})` : "";
console.log(`The join ${expand.name} is ${isRequired}{hasExtra}.`);
// -> The join books is required.
// -> The join editors is required and have an extra filter(current).
// -> The join awards is not required.
});
Members
Methods
# async process(expands, callback)
Processes the expands and calls a callback for each of them.
Parameters:
| Name | Type | Description |
|---|---|---|
expands |
Array.<string>
|
Expands being processed |
callback |
function
|
# setAuthorized(tableNames) → {Expand}
Sets the authorized expands
Parameters:
| Name | Type | Description |
|---|---|---|
tableNames |
Array.<string>
|
List of authorized expand/table names |
Expand
# setRequestUUID(uuid) → {Expand}
Sets the UUID searched in the request. This UUID is used for permissions checks.
Parameters:
| Name | Type | Description |
|---|---|---|
uuid |
*
|
Expand
# setUser(user) → {Expand}
Sets the current user for permission checks.
Parameters:
| Name | Type | Description |
|---|---|---|
user |
module:LoggedUser
|
Expand