You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I was playing around with inheritance, and could not find a way to return the base class, instead of the subclass, when using inheritance. I'll try to explain with an example, that should make it clear:
Say that I have followed the example in the docs and have inserted a few Cars and Buses in the DB, but from different parts of my application, where Car and Bus do not know of each other's existence, and my centralized Vehicle manager does not know of either of them.
So, my question is, is there a way to return Vehicle instances even when the subclasses are not initialized using init_beanie? Currently, it seems to me that this fails because the subclasses are not registered, and the FindInterface._add_class_id_filter method does not have any hooks that allow us to disable this behavior.
The naive solution I came up with is the following:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi! I was playing around with inheritance, and could not find a way to return the base class, instead of the subclass, when using inheritance. I'll try to explain with an example, that should make it clear:
Say that I have followed the example in the docs and have inserted a few
Car
s andBus
es in the DB, but from different parts of my application, whereCar
andBus
do not know of each other's existence, and my centralizedVehicle
manager does not know of either of them.So, my question is, is there a way to return
Vehicle
instances even when the subclasses are not initialized usinginit_beanie
? Currently, it seems to me that this fails because the subclasses are not registered, and theFindInterface._add_class_id_filter
method does not have any hooks that allow us to disable this behavior.The naive solution I came up with is the following:
But I was wondering if there was another, better, way, to solve this.
If not, maybe, this should be mentioned in the docs?
Beta Was this translation helpful? Give feedback.
All reactions