restrictDocument = (document, schema, currentUser) => {
  let restrictedDocument = cloneDeep(document);
  forEachDocumentField(document, schema, ({ fieldName, fieldSchema, currentPath, isNested }) => {
    if (isNested && (!fieldSchema || !fieldSchema.canRead)) return; // ignore nested fields without permissions
    if (!fieldSchema || !Users.canReadField(currentUser, fieldSchema, document)) {
      unset(restrictedDocument, `${currentPath}${fieldName}`);
    }
  });
  return restrictedDocument;
}
Check if user was allowed to filter this document based on some fields
@param {Object} user - The user performing the action
@param {Object} collection - The collection
@param {Object} fields - The list of filtered fields
@param {Object} document - The retrieved document