Nested Objects in Realm React-Native

Viewed 2535

Question

How does Realm React Native perform with two way linking in parent-child nested relationships?

Example

I have an Invoice object, which is made up of InvoiceLines. In the old database, each row in the InvoiceLine table had a reference to its parent Invoice's ID. So a simple 'WHERE ID= " query to get from either an InvoiceLine to its Invoice or an Invoice to all of its InvoiceLines.

In Realm, I'm going to have the following schema (paraphrased):

class Invoice {};
Invoice.schema = {
  name: 'Invoice',
  properties: {
    ...
    lines: {type: 'list', objectType: 'InvoiceLine'}
  }
}

class InvoiceLine {};
InvoiceLine.schema = {
  name: 'InvoiceLine',
  properties: {
    ...
    invoice: 'Invoice',
  }
}

How does the performance of this direct linking compare with using ID's and doing it the traditional way within Realm? Is there a memory tradeoff to store all of those links?

1 Answers
Related