Industries API
Browse and search the list of available industries. Link industries to templates so users can find them in the marketplace.
Overview
Core Concept
The Industries object provides methods for browsing and searching the list of
available industries. Industries are used to categorize templates so users can find relevant
templates when searching the marketplace.
| Property | Type | Description |
|---|---|---|
id | number | Industry ID |
name | string | Industry display name |
code | string | Industry code |
Industries.list()
MethodReturns an array of all available industries.
Returns
An array of {id, name, code} objects.
Example
var industries = Industries.list();
console.log('Total industries: ' + industries.length);
for (var i = 0; i < industries.length; i++) {
console.log(industries[i].id + ': ' + industries[i].name);
}
Industries.findById(id)
MethodFinds an industry by its exact ID.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
number | Yes | The industry ID to find |
Returns
An {id, name, code} object, or null if not found.
Example
var industry = Industries.findById(5);
if (industry) {
console.log(industry.name + ' (code: ' + industry.code + ')');
} else {
console.log('Industry not found');
}
Industries.findByName(name)
MethodFinds an industry by exact name match.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | The exact industry name to find |
Returns
An {id, name, code} object, or null if not found.
Example
var industry = Industries.findByName("Plumbing");
if (industry) {
console.log('ID: ' + industry.id);
console.log('Code: ' + industry.code);
}
Industries.search(query)
MethodSearches industries by partial name or code match. Returns all matching industries.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string | Yes | Partial name or code to search for |
Returns
An array of {id, name, code} objects. Empty array if no matches.
Examples
// Search by partial name
var results = Industries.search("electric");
for (var i = 0; i < results.length; i++) {
console.log(results[i].name);
}
// Output: "Electrical", "Electrical Engineer", etc.
// Search by code
var results = Industries.search("HVAC");
if (results.length > 0) {
console.log('Found: ' + results[0].name);
}
Practical Examples
Code ExamplesLink Industries to a Template
// Find the template
var tpl = Template.findWhere({ name: "Deck Builder" });
if (!tpl) {
console.error("Template not found");
return;
}
// Add relevant industries
var industryNames = ["Carpentry", "General Contractor", "Fencing"];
for (var i = 0; i < industryNames.length; i++) {
var industry = Industries.findByName(industryNames[i]);
if (industry) {
tpl.industries.push(industry.id);
console.log('Linked: ' + industry.name);
} else {
console.warn('Industry not found: ' + industryNames[i]);
}
}
tpl.save();
List All Industries
var all = Industries.list();
console.log('--- Available Industries (' + all.length + ') ---');
for (var i = 0; i < all.length; i++) {
console.log(all[i].id + '. ' + all[i].name + ' [' + all[i].code + ']');
}
Find Related Industries
// Search for construction-related industries
var results = Industries.search("construct");
console.log('Construction-related industries:');
for (var i = 0; i < results.length; i++) {
console.log(' ' + results[i].name);
}