MongoMapper: how do I create a model like this
Posted
by
Vladimir R
on Stack Overflow
See other posts from Stack Overflow
or by Vladimir R
Published on 2011-11-28T00:20:27Z
Indexed on
2011/11/28
1:50 UTC
Read the original article
Hit count: 252
Suppose we have two models, Task and User. So a user can have many tasks and tasks should be able to have many users too. But, a task should also have a unique creator who is also a user.
Exemple:
A task in this context is like this: Task ID, Task Creator, Users who should do the task
User_1 creates a task and he is then the creator. User_1 specifies User_2 and User_3 as users who should do the task. So these two last users are not creators of task.
How do I create this models so that if I have a task object, I can find it's creator and users who should complete it. And how do I do, if I have a user, to find all tasks he created and all tasks he should complete.
Thank you.
© Stack Overflow or respective owner