Wednesday, August 17, 2011

MongoDB relational query and data customization

Lets talk about roles.  Roles, for my implementation, represents an application container.  An account may be granted a permission to this role, and run its applications.


For my relationalness, I always create a role permission collection, p_roles, that links references to the account identifier as well as the role identifier.

This is where my last example came in.  This time, however, I want to populate a grid of accounts that do not exist in a role, so that the interface user may add them to it.  This required two things:
  • an array of account ids we want to exclude
  • a 'not in' query
This example might be more complex than it needs to be, but the complexity lies in keeping each forEach loop asynchronous. I needed to customize the returned data because the accounts collection contains password hashes and other information not necessary for the front end user.

No comments:

Post a Comment