From 50e0cf3090b54a7a7b7e1fe11d6f0e7061cc3d66 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Thu, 25 Nov 2021 17:02:43 -0600 Subject: [PATCH] Fix prototype access issue with model scopes property --- src/orm/model/Model.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/orm/model/Model.ts b/src/orm/model/Model.ts index 2e36c34..b828a7c 100644 --- a/src/orm/model/Model.ts +++ b/src/orm/model/Model.ts @@ -194,7 +194,15 @@ export abstract class Model> extends AppClass implements Bus } } - builder.withScopes(this.prototype.scopes) + if ( this.prototype.scopes ) { + // Same thing here. Try to get the scopes statically, if possible + builder.withScopes(this.prototype.scopes) + } else if ( this.constructor.length < 1 ) { + // Otherwise, try to instantiate the model if possible and load the scopes that way + const inst = Container.getContainer().make>(this) + builder.withScopes(inst.scopes) + } + return builder }