The JSMA categories provides functionality for finding, creating and deleting categories.
What can JSMA categories do for me?The JSMA categories provides access to all the categories (JSMA category) in the database. |
Here is an example on how to write data to a JSMA categories:
... var newCategory = categories.create({ name: 'Anhänger', flexAttributes: { description: 'Ein Anhänger' } }) // => category ... |
Here is an example on how to read data from a JSMA categories:
function doGetCategoryEntries () { var result = { status : "OK", results : [] }; var filter = "*" + request.parameter("filter") + "*"; var filteredCategories = categories.find(filter); var imageId; filteredCategories.forEach( function (category) { if (category.image) { imageId = category.image.uuid; } else { imageId = undefined; } result.results.push({ display : category.title, imageId : imageId, value : category.name }); }); return result; }; |
The JSMA categories provides the following methods:
Creates a new category in the database and returns it as a JSMA category.
This entity is slice aware, which means that to use this facility:
|
... var newCategory = categories.create({ name: 'Anhänger', flexAttributes: { description: 'Ein Anhänger' } }) // => category ... |
An object that may have the following optional keys:
Deletes a category from the database.
This entity is slice aware, which means that to use this facility:
|
... categories.delete(category) ... |
Searches and returns a list of JSMA category from the Sphinx index.
... var filter = "*" + request.parameter("filter") + "*"; var filteredCategories = categories.find(filter, { limit: 5 }); // => [category0, category1, ...] ... |
The search term. May use Extended Sphinx Syntax (http://sphinxsearch.com/docs/archives/1.10/extended-syntax.html)
An object that may have the following optional keys:
Retrieves a single JSMA category by name.
... function Category ( categoryName ) { this.categoryJsma = categories.findByName(categoryName); if (!this.categoryJsma) { throw Error("Category " + categoryName + " could not get resolved"); ... } ... |
The name of a JSMA category in the database.
Retrieves a single JSMA category by uuid
... var categorySearched = categories.findByUuid('246E353D-D6C6-46CB-968E-164DF5CB679C'); // => category ... |
The uuid of a JSMA category.