Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Link users and groups
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andrey  
View profile  
 More options Nov 17 2012, 11:26 am
From: Andrey <trubako...@gmail.com>
Date: Sat, 17 Nov 2012 08:26:34 -0800 (PST)
Local: Sat, Nov 17 2012 11:26 am
Subject: Link users and groups

I'm sorry, but I'm new to Mongodb. I can not understand how to design the
next model.
Collection of users:
[
    {name:'user1', password:'123',
groups:['all_users','author','forum_admin']},
    {name:'user2', password:'123', groups:['all_users','author',]},
    {name:'user3', password:'123', groups:['anonim']}
]
Hierarchy of user groups:
[
    {  _id:'all_users',
       name:'All users',
       groups:[
           {_id:'author', name:'Author'}
           {_id:'anonim', name:'Anonimous user'}
           { _id:'admin',
             name:'Administrator',
             groups:[
                 {_id:'sa', name:'Super administrator'},
                 {_id:'sys_admin', name:'System administrator'},
                 {_id:'forum_admin', name:'Forum administrator'}
             ]
           }
       ]
    }
]

How can I associate users and groups? I tried to add in each user a list of
groups. But I have a problem. *H**ow to extract the group information from
the group hierarchy by them _id?* Request
db.groups.find({_id:'forum_admin'}) return empty list.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Rueckstiess  
View profile  
 More options Nov 18 2012, 11:28 pm
From: Thomas Rueckstiess <Thomas.Ruecksti...@10gen.com>
Date: Sun, 18 Nov 2012 20:28:04 -0800 (PST)
Local: Sun, Nov 18 2012 11:28 pm
Subject: Re: Link users and groups

Hi Andrey,

Just to clarify: Does your groups collection only consist of a single
document where the _id is 'all_users' ? Are you embedding the hierarchy of
all groups into that single document? It looks like that from what you
stated as your Hierarchy of user groups. That would also explain why you
get an empty result when you query for a group with the _id of
"forum_admin", because there is no such document that has that _id on the
top level.

There are several ways to store a group hierarchy in MongoDB:

   - You can use that one-document approach, but then you need to pull the
   complete document to the client side and search the tree for a certain
   subgroup within your application.
   - You can insert one document for each group into the groups collection.
   If you want to keep the hierarchy information, you can add a "parent" field
   that points to the parent group.
   - As above, but instead of pointing to the parent, you can keep the tree
   of sub-groups as a "children" sub-document.

It really depends on what you're planning to do exactly and how your use
case is for the groups. Think about the different situations when you need
access to the groups collection and what answers you want to find. For
example, do you really need the hierarchy every time you query the groups
collection? Or do you mostly just want to get some extra information or
find certain rights of a user's group? There is no one single right answer,
it really depends what you're trying to achieve.

Regards,
Thomas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrey  
View profile  
 More options Nov 23 2012, 1:52 pm
From: Andrey <trubako...@gmail.com>
Date: Fri, 23 Nov 2012 10:52:44 -0800 (PST)
Local: Fri, Nov 23 2012 1:52 pm
Subject: Re: Link users and groups

Thank you for your answer. I decided to use the second method (which is
very similar to the implementation of a relational database). I just thought
that Mongo can do it somehow more elegant.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »