I'm using Realm JS for a React-Native app written in TypeScript and I'm wondering about the typing of Realm.Results.
here is my use case:
My Schema for 'MessageData' is:
export const MessageDataSchema = { name: 'MessageData', primaryKey: 'id', properties: { id: 'string', messages: { type: 'list', objectType: 'Message' }, }}
Here is the typing is use to fetch data from the database (fetches the MessageData of a particular conversation, with its conversationId).
const databaseMessages: Realm.Results<MessageData> = realm.objectForPrimaryKey<Realm.Results<MessageData>>('MessageData', conversationId)
With this type, I get an error further down my code when I add a listener to the database:
Property 'messages' does not exist on type 'Results'.ts(2339)
databaseMessages.addListener(() => {setMessages([...databaseMessages.messages]);});
any thoughts why this might be happening? thanks a lot!