Skip to content

Instantly share code, notes, and snippets.

@flancer64
Created March 12, 2024 08:46
Show Gist options
  • Save flancer64/fa711ef77324338261a11e6d3aaa633f to your computer and use it in GitHub Desktop.
Save flancer64/fa711ef77324338261a11e6d3aaa633f to your computer and use it in GitHub Desktop.
The template for a Data Transfer Object (DTO) code used in the TeqFW framework.
/**
* The format in which the exported/imported information is organized.
*/
// MODULE'S VARIABLES
const NS = 'TeqFw_Db_Back_Dto_Export';
// MODULE'S CLASSES
/**
* @memberOf TeqFw_Db_Back_Dto_Export
*/
class Dto {
static namespace = NS;
/**
* Contains all tables with data.
* @type {Object}
*/
rows;
/**
* Contains all serials (for PostgreSQL DBs).
* @type {Object}
*/
serials;
}
/**
* @implements TeqFw_Core_Shared_Api_Factory_Dto
*/
export default class TeqFw_Db_Back_Dto_Export {
/**
* @param {TeqFw_Core_Shared_Util_Cast} cast
*/
constructor(
{
TeqFw_Core_Shared_Util_Cast$: cast,
}
) {
/**
* @param {TeqFw_Db_Back_Dto_Export.Dto} [data]
* @return {TeqFw_Db_Back_Dto_Export.Dto}
*/
this.createDto = function (data) {
// create a new DTO
const res = new Dto();
// cast known attributes
res.rows = cast.object(data?.rows);
res.serials = cast.object(data?.serials);
return res;
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment