Filter on string or Tag[]


#1

Hi,

From my research Realm does not yet support filtering on arrays of primitives. So I cannot filter on an array of strings. Is this correct?

This is far from ideal, but I have researched two workarounds for my use case.

Use case

I need to filter on a set of tags. These tags will be strings. What would be the most optimial schema for filtering on the metaTag field? We would need to chain multiple OR statements (e.g. metaTag CONTAINS ‘TAG1’ OR metaTag CONTAINS ‘TAG2’ OR metaTag CONTAINS ‘TAG3’ …many other tags… OR metaTag CONTAINS ‘TAG100’ etc.)

Schema 1.

export const MessageSchema = {
  name: "Message",
  primaryKey: "uuid",
  properties: {
    uuid: "string",
    source: "string",
    incidentType: "int?",
    metaTag: "string",
    sentUtcTimestamp: "date",
    expiryUtcTimestamp: "date",
	}
}

The data stored in the metaTag field would look something like: [TYRELL_ADDRESS:Dev Receiver- Docker 91],[1C42],[W00033],[TRAIN_CANCELLED]

Schema 2.

export const MessageSchema = {
  name: "Message",
  primaryKey: "uuid",
  properties: {
    uuid: "string",
    source: "string",
    incidentType: "int?",
    metaTag: "Tag[]",
    sentUtcTimestamp: "date",
    expiryUtcTimestamp: "date",
	}
}
export const TagSchema = {
  name: "Tag",
  primaryKey: "value",
  properties: {
    value: "string",
	}
}

The data stored in the metaTag field would look something like:

[
TYRELL_ADDRESS:Dev Receiver- Docker 91,
1C42,
W00033,
TRAIN_CANCELLED
]

I would like to get the best performance from Realm, therefore any help or recommendations would be gratefully received.

Many thanks.