code: def active_user_organisations_resource(doc):
      
      if doc.get('type') == 'user' and doc.get('state') != 'deactivated':
          for org_id, resource in doc.get('organisations', {}).items():
              if resource['state'] != 'deactivated':
                  resource['id'] = org_id
                  resource['user_id'] = doc['_id']
                  yield [doc['_id'], org_id], resource
docs: Get user.organisations subresouces