ezobjects-mysql
Advanced tools
Comparing version 3.1.3 to 4.0.0
@@ -61,3 +61,3 @@ /** Require external modules */ | ||
{ name: `functionExample2`, type: `function`, store: true }, | ||
{ name: `plainObjectExample`, type: `object` }, | ||
{ name: `plainObjectExample`, type: `PlainObject` }, | ||
{ name: `ezobjectTypeExample`, type: `OtherObj` }, | ||
@@ -103,3 +103,3 @@ { name: `ezobjectInstanceExample`, instanceOf: `OtherObj` }, | ||
{ name: `functionArrayExample2`, type: `Array`, arrayOf: { type: `function`, store: true } }, | ||
{ name: `plainObjectArrayExample`, type: `Array`, arrayOf: { type: `object` } }, | ||
{ name: `plainObjectArrayExample`, type: `Array`, arrayOf: { type: `PlainObject` } }, | ||
{ name: `ezobjectTypeArrayExample`, type: `Array`, arrayOf: { type: `OtherObj` } }, | ||
@@ -106,0 +106,0 @@ { name: `ezobjectInstanceArrayExample`, type: `Array`, arrayOf: { instanceOf: `OtherObj` } }, |
const docket = require(`docket-parser`); | ||
docket.title(`EZ Objects v3.1.3`); | ||
docket.title(`EZ Objects v4.0.0`); | ||
docket.linkClass(`text-success`); | ||
docket.parseFiles([`index.js`, `mysql-connection.js`]); | ||
docket.generateDocs(`docs`); |
12
index.js
@@ -44,4 +44,4 @@ /** | ||
throw new TypeError(`${property.className}.${property.name}(): Non-Set value passed to '${property.type}' setter.`); | ||
else if ( x && property.ezobjectType.jsType == 'Object' && ( typeof x !== 'object' || x.constructor.type == 'Object' ) ) | ||
throw new TypeError(`${property.className}.${property.name}(): Non-Object value passed to '${property.type}' setter.`); | ||
else if ( x && property.ezobjectType.jsType == 'PlainObject' && ( typeof x !== 'object' || x.constructor.type == 'Object' ) ) | ||
throw new TypeError(`${property.className}.${property.name}(): Non-PlainObject value passed to '${property.type}' setter.`); | ||
else if ( x && property.ezobjectType.jsType == 'object' && ( typeof x !== 'object' || ( typeof property.type == 'string' && x.constructor.name != property.originalType ) || ( typeof property.instanceOf === 'string' && !module.exports.instanceOf(x, property.instanceOf) ) ) ) | ||
@@ -85,4 +85,4 @@ throw new TypeError(`${property.className}.${property.name}(): Invalid value passed to '${typeof property.type === 'string' ? property.originalType : property.instanceOf}' setter.`); | ||
throw new TypeError(`${property.className}.${property.name}(): Non-Set value passed as element of Array[${property.arrayOf.type}] setter.`); | ||
else if ( property.ezobjectType.jsType == 'Object' && x && x.some(y => ( typeof y !== 'object' || y.constructor.name != 'Object' ) && y !== null) ) | ||
throw new TypeError(`${property.className}.${property.name}(): Non-Object value passed as element of Array[${property.arrayOf.type}] setter.`); | ||
else if ( property.ezobjectType.jsType == 'PlainObject' && x && x.some(y => ( typeof y !== 'object' || y.constructor.name != 'Object' ) && y !== null) ) | ||
throw new TypeError(`${property.className}.${property.name}(): Non-PlainObject value passed as element of Array[${property.arrayOf.type}] setter.`); | ||
else if ( property.ezobjectType.jsType == 'object' && x && x.some(y => y !== null && (typeof y !== 'object' || ( typeof property.arrayOf.type == 'string' && y.constructor.name != property.arrayOf.type ) || ( typeof property.arrayOf.instanceOf === 'string' && !module.exports.instanceOf(y, property.arrayOf.instanceOf) ))) ) | ||
@@ -157,3 +157,3 @@ throw new TypeError(`${property.className}.${property.name}(): Invalid value passed as element of Array[${typeof property.arrayOf.type === 'string' ? property.arrayOf.type : property.arrayOf.instanceOf}] setter.`); | ||
{ type: `function`, jsType: `function`, mysqlType: `text`, default: function () {}, setTransform: setTransform, saveTransform: x => x.toString(), loadTransform: x => eval(x) }, | ||
{ type: `object`, jsType: `Object`, mysqlType: `text`, default: {}, setTransform: setTransform, saveTransform: x => JSON.stringify(x), loadTransform: x => JSON.parse(x) }, | ||
{ type: `plainobject`, jsType: `PlainObject`, mysqlType: `text`, default: {}, setTransform: setTransform, saveTransform: x => JSON.stringify(x), loadTransform: x => JSON.parse(x) }, | ||
{ type: `other`, jsType: `object`, mysqlType: `int`, default: null, setTransform: setTransform, saveTransform: x => x ? x.id() : -1, loadTransform: async (x, property, db) => await (new parent[typeof property.type === 'string' ? property.originalType : property.instanceOf]).load(x, db) }, | ||
@@ -194,3 +194,3 @@ | ||
{ type: `array`, jsType: `Array`, mysqlType: `mediumtext`, default: [], arrayOfType: `function`, setTransform: setArrayTransform, saveTransform: x => x.map(y => y.toString()).join(`!&|&!`), loadTransform: x => x.split(`!&|&!`).map(y => eval(y)) }, | ||
{ type: `array`, jsType: `Array`, mysqlType: `mediumtext`, default: [], arrayOfType: `object`, setTransform: setArrayTransform, saveTransform: x => JSON.stringify(x), loadTransform: x => JSON.parse(x) }, | ||
{ type: `array`, jsType: `Array`, mysqlType: `mediumtext`, default: [], arrayOfType: `PlainObject`, setTransform: setArrayTransform, saveTransform: x => JSON.stringify(x), loadTransform: x => JSON.parse(x) }, | ||
{ type: `array`, jsType: `Array`, mysqlType: `text`, default: [], arrayOfType: `other`, setTransform: setArrayTransform, saveTransform: x => x.map(y => y.id()).join(`,`), loadTransform: async (x, property, db) => { const arr = []; for ( let i = 0, list = x.split(`,`), i_max = list.length; i < i_max; i++ ) { if ( !isNaN(parseInt(list[i])) ) arr.push(await (new parent[typeof property.arrayOf.type === 'string' ? property.arrayOf.type : property.arrayOf.instanceOf]).load(parseInt(list[i]), db)); } return arr; } } | ||
@@ -197,0 +197,0 @@ ]; |
{ | ||
"name": "ezobjects-mysql", | ||
"version": "3.1.3", | ||
"version": "4.0.0", | ||
"description": "Easy dynamic object generation with optional MySQL table linking", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
411484