开发者

Reference Embedded Object in Mongodb

开发者 https://www.devze.com 2023-02-15 11:52 出处:网络
I have a collection in Mongodb( Users ) and a collection ( GroupTask ) GroupTask has embedded ( Task ) objects.

I have a collection in Mongodb( Users ) and a collection ( GroupTask )

GroupTask has embedded ( Task ) objects.

How can I have Users referencing a Specific Task object inside a Specific GroupTask Object?

EDIT::

My user table is:

Username

Password

OpenIDurl

MemberSince

Role/Permissions

GroupTask is

Name

DateStarted

CompletionDate

NumberOfTasks

NumberOfSubscribedUsers

<<Tasks>> // Embedded array

A task is:

Name

Description

DateStarted

DateCompleted

Progress

Each user needs to reference many tasks and each task can开发者_StackOverflow中文版 have more than one user. The only problem is that task is embedded into task group.


It is difficult to answer without more information on your application and its access patterns and how you plan to use this data. A similar situation with products and categories is discussed in http://www.scribd.com/doc/47326395/MongoBoulder-Schema-Design


I think you need to embed some of the fields of your user objects into your GroupTask objet, like PK, username, email. And if you change any user object, fire an update in GroupTask collection.

0

精彩评论

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