-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is _type
used for?
#23
Comments
'_type' is designed for retrieving a inheritance model.
When retrieving a model,if we found this model have a parent class,we add '_type' to query params. Query ['_type'=>'Dog']
Query ['_type'=>'Mammal'] , Of course Dog belongs to Mammal,so we must retrieve the right dog .
So in the db,the document of dog have a '_type' like this: ['Animal','Mammal','Dog'] |
And you says right , I also think the current method is not a very good solution . we must have some ways to optimize these code. |
So in short this enables the ability to fetch all documents related to the parent branch. FunctionalityCurrently one can take class Person extends Model {
public $collection = 'people';
}
class Faculty extends Person {}
class Tenyear extends Faculty {}
class Visiting extends Faculty {}
class Staff extends Person {}
class IT extends Staff {}
class Tenyear extends IT {}
class Financial extends Staff {}
class Student extends Person {
public $collection = 'student';
} one would expect Person::one() // latest person in or extending Person (i.e. Faculty, Tenyear, Visiting, Staff, IT, etc...)
Faculty::one() // latest person in or extending Faculty
IT::one() // latest person in or extending IT
//.... Issues
Possible Solutions
|
@purekid do you have any more thoughts on this? |
@jrschumacher,i have some ideas but not clear.I will do some test this night at home ,then continue here. |
@purekid Any thoughts about this? |
Also need to consider indexing cost of this. I've been running dex and it seems this has a cost on collections. |
I am assuming it is used to maintain the association of an object if it doesn't have it's own collection like this.
However it adds a lot of unnecessary overhead to store
_type
unless someone is storing the different documents in the same collection. Let me know if this the only function because I want to build a dynamic switch (i.e. if there is no collection defined then set _type else omit)Also I would suggest switching to a string rather than array. It is easier on the database with regards to storage and memory and would permit indexing. (i.e.
Base\Person\Student
)The text was updated successfully, but these errors were encountered: