Document_filter based on user identities

Hi. I’ve seen many filter based on user custom data and I could insert the field I want in there but I was wondering if I can use something in the identities array? I tried this:

{
  "roles": [
    {
      "name": "owner-read-write",
      "apply_when": {},
      "document_filters": {
        "read": { "createdBy": "%%user.identities[0].id" },
        "write": { "createdBy": "%%user.identities[0].id" }
      },
      "read": true,
      "write": true
    }
  ]
}

But it doesn’t work (it works in functions) so I’m wondering if it’s just not possible.

Another thing I wanted to know is if I can do something like

{
  "name": "owner-read-write",
  "apply_when": {},
  "document_filters": {
    "read": {
      "owner_id": {
        "$in": "%%db.anotherCollection.user_ids"
      }
    },
    "write": { "owner_id": "%%user.id" }
  },
  "read": true,
  "write": true
}

or something similar?

Hey @Gustavo_Parrado ,

Out of curiosity, does something like:

{
  "roles": [
    {
      "name": "owner-read-write",
      "apply_when": {},
      "document_filters": {
        "read": { "createdBy": { $in: "%%user.identities.id" } },
        "write": { "createdBy": { $in: "%%user.identities.id" } },
      },
      "read": true,
      "write": true
    }
  ]
}

work? I think the [0] in the expansion in the first example is likely not getting processed in the way you’d expect.