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

Caching distinct() #52

Open
juona opened this issue Jun 3, 2019 · 1 comment
Open

Caching distinct() #52

juona opened this issue Jun 3, 2019 · 1 comment

Comments

@juona
Copy link

juona commented Jun 3, 2019

Somewhat similar to #25.

Distinct returns an array of ObjectIDs rather than an array of Models, which appears to confuse the caching mechanism. Is there any way to fix it easily?

@CiaranMn
Copy link

I've just come across this - each ObjectId in the array gets converted to an object of the relevant Model, where the object has keys of numbers from 0 to 23 and the values are the 24 characters of the ObjectId. It also includes any fields Mongoose would include in an object of the Model, e.g. fields defined in the schema with defaults or as an array.

{
  '0': '5',
  '1': 'd',
  '2': 'c',
  '3': '1',
  '4': '5',
  // ...and so on for the whole ObjectId
  someArrayFieldInSchema: [],
  someFieldWithDefault: 0
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants