Basic Model example for the MVC Pattern

PHOTO EMBED

Mon Apr 08 2024 14:38:43 GMT+0000 (Coordinated Universal Time)

Saved by @jamzlego #nodejs

const getData = require('../js/utility/getData');

module.exports = class Data {

  static getPartnerData() {
    return getData.getFileData().partners;
  }

  static getServicesData() {
    return getData.getFileData().services;
  }

  static getPricingData() {
    return getData.getFileData().prices;
  }

  static getFeatures() {
    return getData.getFileData().features;
  }

  static getValues() {
    return getData.getFileData().values;
  }

  static getStats() {
    return getData.getFileData().stats;
  }
}
content_copyCOPY

Directory name: models Filename: data.js For this snippet the data was being read from a file. When a database is involved the code will change slightly to reflect the functions needed to query the data from an actual database.