Mongoid: How to load only some fields of an object you lazy load via reference?

前端 未结 2 657
忘掉有多难
忘掉有多难 2021-01-17 18:05

For performance reason, I use as often as possible the only() keyword when writing up a mongoid query in order to specify the fields I want to load.

The

相关标签:
2条回答
  • 2021-01-17 18:25

    I think you need to denormalize here. First of all, read A Note on Denormalization.

    You can implement denormalization by self using mongoid events or use great mongoid_denormalize gem. It pretty straight and after implementing it you could use p.user_email or something in your queries.

    0 讨论(0)
  • 2021-01-17 18:27

    Answer from creator of Mongoid. It's not possible yet. It's been added as feature request.

    0 讨论(0)
提交回复
热议问题