Note that there are some explanatory texts on larger screens.

plurals
  1. POHow should I record in the database that an item/product is visible by 'all' groups?
    primarykey
    data
    text
    <p>A user can be in groups. And an item/product is assigned groups that can see the item. Users can see that item if they are in one of the assigned groups.</p> <p>I want neither public (anonymous users in no groups) nor groupless users (logged in users not in any groups) to see the item. But I want the interface to allow assigning the item an 'all/any groups' attribute so that users that are in any group at all can see the item.</p> <p>Where/How should I store this assignment?</p> <p>p.s. I expect the technique to also be extended to other entities, for example I'd assign a file to a category, and groups are linked to categories. so when a file is marked as visible by the 'all/any category' then if the user (thru groups and group-categories) is linked to at least one category then the file is visible to them.</p> <p><strong>Decision:</strong></p> <p>It seemed the choice was whether to implement as a row in a entity-groups table or as fields in the entity table. The chosen answer used the former.</p> <p>And either managing the group membership in a table or adding JOIN conditions. The chosen answer used the former, but I'm going to use the latter. I'm putting an indirection between the query and usage so if (when) performance is a problem I should be able to change to a managed table underneath (as suggested) without changing usage.</p> <p>I've other special groups like 'admin', 'users', etc. which can also fit into the same concept (the basis simply being a list of groups) more easily than special and variable field handling for each entity.</p> <p>thanks all.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload