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.

Industry Object: All methods return objects with these properties:
PropertyTypeDescription
idnumberIndustry ID
namestringIndustry display name
codestringIndustry code

Industries.list()

Method

Returns 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)

Method

Finds an industry by its exact ID.

Parameters

ParameterTypeRequiredDescription
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)

Method

Finds an industry by exact name match.

Parameters

ParameterTypeRequiredDescription
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);
}

Practical Examples

Code Examples

Link 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);
}