Skip to content
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

Querying aliases feature #5321

Closed
rkt2spc opened this issue Jun 3, 2017 · 6 comments
Closed

Querying aliases feature #5321

rkt2spc opened this issue Jun 3, 2017 · 6 comments
Labels
new feature This change adds new functionality, like a new method or class

Comments

@rkt2spc
Copy link
Contributor

rkt2spc commented Jun 3, 2017

Following #5184, I now want to implement the ability to query (and update) based on aliased fields. I've been looking at the code for a while. At first, I was looking for ways to apply an option for aliasing on each and every model query. But then, I came up with another solution, which looks something like:

var Foo = mongoose.Model('Foo', FooSchema);

Foo.findOneAndUpdate(
    Foo.translateAliases({aliasedField: ...}),
    Foo.translateAliases({aliasedField: ...})
)

Which I think is neater, clearer, and obviously optional. Plus, this won't change our codebase too much, avoiding cases when we forgot to do conditions aliasing in some queries.

I want to know if you feel okay going down this approach, so I put it here for feedback

@rkt2spc rkt2spc changed the title Querying aliases Querying aliases feature Jun 3, 2017
@vkarpov15
Copy link
Collaborator

translateAliases() would definitely be a great step towards making aliases work seamlessly. If that function works, we can easily add it as a hook and then have it work transparently. Good idea 👍

@vkarpov15 vkarpov15 added the new feature This change adds new functionality, like a new method or class label Jun 7, 2017
@wong2
Copy link

wong2 commented Nov 13, 2017

any progress?

@vkarpov15
Copy link
Collaborator

Nope not yet

@rafaelcorreiapoli
Copy link

Anu updates on this?

@vkarpov15
Copy link
Collaborator

@rafaelcorreiapoli no, not yet. Will bump this up for the next minor version.

@vkarpov15 vkarpov15 added this to the 5.7 milestone Jul 25, 2019
@vkarpov15
Copy link
Collaborator

I didn't quite read this thread carefully, it looks like this was fixed by #5338. Here's the docs for Model.translateAlias() @rafaelcorreiapoli

@vkarpov15 vkarpov15 removed this from the 5.7 milestone Aug 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This change adds new functionality, like a new method or class
Projects
None yet
Development

No branches or pull requests

4 participants