PropDbLoader
Per model property database interface, talks to the worker thread behind the scenes.
Methods
getProperties(dbId, onSuccess, onError)
Gets the properties for an ID.
Parameters
dbId* number | The database identifier. |
onSuccess | Callback for when the properties are fetched. |
onError | Callback for when the properties are not found or another error occurs. |
getProperties2(dbId, onSuccess, onError, options)
Gets the properties for an ID. New version of getProperties() that avoids loading of externalId table unless really needed.
Parameters
dbId* number | The database identifier. |
onSuccess | Callback for when the properties are fetched. |
onError | Callback for when the properties are not found or another error occurs. |
options object | |
needsExternalId boolean | If true, we enforce loading of externalIDs if necessary. ExternalIds may significantly increase memory consumption and should only be loaded if unavoidable. |
getBulkProperties2(dbIds, options, onSuccess, onError)
Bulk property retrieval with property name filter.
Parameters
dbIds* Array.<number> | array of object dbIds to return properties for. |
options object | |
propFilter Array.<string> | array of property names to retrieve values for. If empty, all properties are returned. |
categoryFilter Array.<string> | array of category names to retrieve values for. If empty, all properties are returned. |
ignoreHidden boolean | true to ignore hidden properties. |
needsExternalId boolean | If true, it is ensured that externalId table is loaded before doing the property query. |
onSuccess* function | Callback function for when results are ready. |
onError* function | Callback function for when something went wrong. |
getPropertySet(dbIds, options, onSuccess, onError)
Retrieves properties related to the specified dbIds. The results object that is passed into the onSuccess callback contains the displayName and displayCategory separated by a ‘/’ as the key and all of the related properties as the entry’s value. The results can be used to create a new PropertySet instance.
Parameters
dbIds* Array.<number> | array of object dbIds to return properties for. |
options Object | |
propFilter Array.<string> | array of property names to retrieve values for. If empty, all properties are returned. |
ignoreHidden boolean | true to ignore hidden properties. |
needsExternalId boolean | If true, it is ensured that externalId table is loaded before doing the property query. |
onSuccess* function | Callback function for when results are ready. |
onError* function | Callback function for when something went wrong. |
executeUserFunction(code, userData)
Allows executing user supplied function code on the worker thread against the PropertyDatabase instance. The returned value from the supplied function will be used to resolve the returned Promise. The function must be named userFunction
.
Parameters
code* function, string | Function takes 1 argument, the PropertyDatabase instance. |
userData* | A value that will get passed to the code function when run in the property worker context. it needs to be serializable. |
Returns
type | description |
---|---|
Promise |
|
Examples
function userFunction(pdb, userData) {
const dbId = 1;
pdb.enumObjectProperties(dbId, function(propId, valueId) {
// do stuff
});
return 42 * userData; // userData will be 2 in this example
}
executeUserFunction(userFunction, 2).then(function(result) {
console.log(result); // result === 84 === 42 * 2
})
This example, however, only works on non-minfied/non-uglified code. Minification or other obfuscation techniques that change the function name will cause an error, with the userFunction not found. In that cases, a string must be used.
await executeUserFunction('function userFunction(pdb, userData) { ... }');
getLoadProgress()
Estimated load progress in percent.
Returns
type | description |
---|---|
number | in the range 0..100 |
isLoadDone()
Returns true if loading is finished (either with success or with error)
Returns
type | description |
---|---|
boolean |