diff --git a/src/db/ModelRelation.ts b/src/db/ModelRelation.ts index c3d5116..71ce60b 100644 --- a/src/db/ModelRelation.ts +++ b/src/db/ModelRelation.ts @@ -3,7 +3,7 @@ import ModelFactory from "./ModelFactory.js"; import ModelQuery, {ModelFieldData, ModelQueryResult, WhereTest} from "./ModelQuery.js"; export default abstract class ModelRelation { - protected readonly model: S; + protected readonly _model: S; protected readonly foreignModelType: ModelType; protected readonly dbProperties: RelationDatabaseProperties; protected readonly queryModifiers: QueryModifier[] = []; @@ -11,7 +11,7 @@ export default abstract class ModelRelation, dbProperties: RelationDatabaseProperties) { - this.model = model; + this._model = model; this.foreignModelType = foreignModelType; this.dbProperties = dbProperties; } @@ -35,7 +35,7 @@ export default abstract class ModelRelation): void { @@ -111,7 +111,7 @@ export class OneModelRelation extends ModelRel } public clone(): OneModelRelation { - return new OneModelRelation(this.model, this.foreignModelType, this.dbProperties); + return new OneModelRelation(this._model, this.foreignModelType, this.dbProperties); } protected collectionToOutput(models: O[]): O | null { @@ -119,11 +119,11 @@ export class OneModelRelation extends ModelRel } public async set(model: O): Promise { - (this.model as Model)[this.dbProperties.localKey] = model[this.dbProperties.foreignKey]; + (this._model as Model)[this.dbProperties.localKey] = model[this.dbProperties.foreignKey]; } public async clear(): Promise { - (this.model as Model)[this.dbProperties.localKey] = undefined; + (this._model as Model)[this.dbProperties.localKey] = undefined; } } @@ -139,11 +139,11 @@ export class ManyModelRelation extends ModelRe } public clone(): ManyModelRelation { - return new ManyModelRelation(this.model, this.foreignModelType, this.dbProperties); + return new ManyModelRelation(this._model, this.foreignModelType, this.dbProperties); } public cloneReduceToOne(): OneModelRelation { - return new OneModelRelation(this.model, this.foreignModelType, this.dbProperties); + return new OneModelRelation(this._model, this.foreignModelType, this.dbProperties); } protected collectionToOutput(models: O[]): O[] { @@ -178,7 +178,7 @@ export class ManyThroughModelRelation extends } public clone(): ManyThroughModelRelation { - return new ManyThroughModelRelation(this.model, this.foreignModelType, this.dbProperties); + return new ManyThroughModelRelation(this._model, this.foreignModelType, this.dbProperties); } public cloneReduceToOne(): OneModelRelation { @@ -229,7 +229,7 @@ export class RecursiveModelRelation extends ManyModelRelation { - return new RecursiveModelRelation(this.model, this.foreignModelType, this.dbProperties); + return new RecursiveModelRelation(this._model, this.foreignModelType, this.dbProperties); } public async populate(models: ModelQueryResult): Promise { diff --git a/src/frontend/SvelteViewEngine.ts b/src/frontend/SvelteViewEngine.ts index 5a87df4..aa489fc 100644 --- a/src/frontend/SvelteViewEngine.ts +++ b/src/frontend/SvelteViewEngine.ts @@ -76,6 +76,7 @@ export default class SvelteViewEngine extends ViewEngine { const localMap: Record = this.compileBackendCalls(backendCalls.split('\n'), locals, false); const actualLocals = JSON.stringify(localMap, (key, value) => { + if (key.startsWith('_')) return undefined; return typeof value === 'function' ? value.toString() : value;