-
Notifications
You must be signed in to change notification settings - Fork 45
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
Find query at child #26
Comments
+1 |
3 similar comments
+1 |
+1 |
+1 |
I've forked the project and am working on implementing this. Will issue a pull request soon. |
If anyone wants to take a look a progress so far, and possibly contribute, the fork is at https://github.com/okpanda/mongoose-schema-extend Note that this hasn't been extensively tested yet. |
I will check it, thanks for your work @loudwinston |
Another quick implementation is to use pre hooks to inject the discriminatorKey into conditions: 99 var patchDiscriminatorKey = function() {
100 this._conditions[key] = this.model.modelName;
101 };
102
103 newSchema.pre('find', patchDiscriminatorKey);
104 newSchema.pre('findOne', patchDiscriminatorKey);
105 newSchema.pre('count', patchDiscriminatorKey);
106 newSchema.pre('findOneAndRemove', patchDiscriminatorKey);
107 newSchema.pre('findOneAndUpdate', patchDiscriminatorKey);
108 newSchema.pre('update', patchDiscriminatorKey); |
i add above line. after that facing some problem. Hi, staff.save() saving data with Discriminator Key __t ='sfaff' in plugin i did changes ` var patchDiscriminatorKey = function() { newSchema.pre('find', patchDiscriminatorKey); return newSchema; |
I am trying to use a test case as described in "mongoose-schema-extend"
All is working just as explained there.
But, I would expect it to give me the ability to do a search query on the inherited type. So if we consider the example showed in the link above:
I would expect
Car.find({})
to return only the documents which have_type : Car
. Instead, I get all vehicles.Is there a way to get only the cars except for doing
Car.find{"_type":"Car"})
?The text was updated successfully, but these errors were encountered: