Files
legolog/src/database/psql-entity-framework/model.js
Ben ecd1db04c3 kinda conflict resolution
Former-commit-id: 5280da65bc8b2f8e94a7e15bac215656aefffc40
2022-02-11 17:55:55 +00:00

43 lines
1.2 KiB
JavaScript

const Logger = require('../../logger.js');
const DataTypes = require('./types.js');
/**
* @class Model
* @classdesc The Model class is used to create a model instance.
* @param {string} name - The name of the model
* @param {object} properties - The properties of the model
* @param {boolean} dummy - Whether or not the model is a dummy model
*/
class Model {
constructor(name, properties, dummy = false) {
this.name = name;
this.properties = properties;
this.dummy = dummy;
if (dummy)
Logger.Database(`Model ${name} is dummy: ${dummy}`);
Logger.Database(`Model ${name} created, with properties: ${JSON.stringify(properties)}`);
}
/**
* @function property
* @description Gets a property from the model
* @param {string} name - The name of the target property
*/
property(name) {
if (this.dummy)
{
this.properties[name] = {
type: DataTypes.INHERET,
constraints: [],
dummy: true
}
return "UNRESOVLED PROPERTY";
}
return this.property[name];
}
}
module.exports = Model;