Add a new instance of SettingGateway, with its own validateFunction and schema.
Parameters:
Name |
Type |
Argument |
Default |
Description |
name |
string
|
|
|
The name for the new instance. |
validateFunction |
function
|
|
|
The function that validates the input. |
schema |
Object
|
<optional>
|
{}
|
The schema. |
- Source:
-
lib/settings/SettingsCache.js#L57
Returns:
-
Type
-
SettingGateway
Example
// Add a new SettingGateway instance, called 'users', which input takes users, and stores a quote which is a string between 2 and 140 characters.
const validate = async function(resolver, user) {
const result = await resolver.user(user);
if (!result) throw 'The parameter <User> expects either a User ID or a User Object.';
return result;
};
const schema = {
quote: {
type: 'String',
default: null,
array: false,
min: 2,
max: 140,
},
};
SettingsCache.add('users', validate, schema);