PropertyProvider
Summary
Defines a PropertyProvider to get and save custom properties.
Constructor
PropertyProvider
Syntax
PropertyProvider
-
database
Summary
Parameters:
-
database
DatabaseThe database to interact with
Methods
add
Syntax
add
-
customProperties
-
[callback]
Summary
Adds custom properties.
Parameters:
-
customProperties
ArrayThe list of custom properties to store with for each custom property:
- String name The property name
- String description The property description
- String type The property type (see PropertyProvider.availableTypes)
- String [id] The property id, generated if not specified
- Array [values] The list of values if type is PropertyProvider.TYPES.LIST
-
[callback]
Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The total amount of properties inserted
- Array The list of added properties
createIndexes
Syntax
createIndexes
-
callback
Summary
Creates properties indexes.
Parameters:
-
callback
FunctionFunction to call when it's done with :
- Error An error if something went wrong, null otherwise
remove
Syntax
remove
-
[filter]
-
[callback]
Summary
Removes custom properties.
This will execute publish hook "PROPERTIES_DELETED" after removing custom properties with:
- Array The list of removed properties
Parameters:
-
[filter]
ResourceFilter optionalRules to filter properties to remove
-
[callback]
Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number The number of removed properties
updateOne
Syntax
updateOne
-
[filter]
-
data
-
[callback]
Summary
Updates a custom property.
Parameters:
-
[filter]
ResourceFilter optionalRules to filter property to update
-
data
ObjectThe modifications to perform
-
[name]
String optionalThe property name
-
[description]
String optionalThe property description
-
[type]
String optionalThe property type (see PropertyProvider.availableTypes)
-
[id]
String optionalThe property id, generated if not specified
-
[values]
Array optionalThe list of values if type is PropertyProvider.TYPES.LIST
-
-
[callback]
Function optionalThe function to call when it's done
- Error The error if an error occurred, null otherwise
- Number 1 if everything went fine