开发者

Restrict embedded docs in query with Mongoid

I'm writing a quick little money tracking rails app for fun that allows a user to enter their daily bills. I have a user embeds_many :bills.

I'm using Devise for auth. Here's my question. When I fetch current_user each time from my session_id, it's going to pull in my whole user and its embedded docs correct? So as bills add up, my user object will become larger and larger.

I'm wonde开发者_Go百科ring if there's any way I can restrict this so that my current_user find doesn't fetch the embedded docs, otherwise I don't think it makes sense to embed these bills within the user, but rather use a relationship on a separate bills collection.

Anyone have any thoughts on this?


I like the concept of having a user object that's tied to Devise, and a Profile object that defines that user's attributes and information.

So your user would have a profile, and the profile would have embedded bills.

That way you only grab the profile information when needed, which might be often, but won't be every single page load.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜