98 lines
2.8 KiB
HTML
98 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Source: model.js</title>
|
|
|
|
<script src="scripts/prettify/prettify.js"> </script>
|
|
<script src="scripts/prettify/lang-css.js"> </script>
|
|
<!--[if lt IE 9]>
|
|
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
<![endif]-->
|
|
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="main">
|
|
|
|
<h1 class="page-title">Source: model.js</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article>
|
|
<pre class="prettyprint source linenums"><code>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, referer = "") {
|
|
if (this.dummy)
|
|
{
|
|
if (this.properties[name]) {
|
|
this.properties[name].referers.push(referer);
|
|
}
|
|
this.properties[name] = {
|
|
type: DataTypes.INHERET,
|
|
referers: [referer],
|
|
constraints: [],
|
|
dummy: true
|
|
}
|
|
return "UNRESOVLED PROPERTY";
|
|
}
|
|
return this.property[name];
|
|
}
|
|
}
|
|
|
|
module.exports = Model;
|
|
</code></pre>
|
|
</article>
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<nav>
|
|
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Database.html">Database</a></li><li><a href="Model.html">Model</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addModel">addModel</a></li><li><a href="global.html#model">model</a></li><li><a href="global.html#property">property</a></li><li><a href="global.html#resolveDependants">resolveDependants</a></li><li><a href="global.html#syncModels">syncModels</a></li></ul>
|
|
</nav>
|
|
|
|
<br class="clear">
|
|
|
|
<footer>
|
|
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Sat Feb 12 2022 03:04:16 GMT+0000 (Greenwich Mean Time)
|
|
</footer>
|
|
|
|
<script> prettyPrint(); </script>
|
|
<script src="scripts/linenumber.js"> </script>
|
|
</body>
|
|
</html>
|