realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Inherit base model in other models

Open arahmanali opened this issue 7 years ago • 3 comments

So i read the doc but it didnt help, What i have is a base model which has some common fields and i want to inherit those in my all other models. My Base Model:

class Base { }

Base.schema = {
  name: 'Base',
  properties: {
    uuid: { type: 'string', optional: false },
    created_by: { type: 'string', optional: false },
  }
};

My Other Model:

class Student { }

Student.schema = {
  name: 'Student',
  properties: {
    name: { type: 'string', optional: false },
    age: { type: 'int', optional: true }
    ...
  }
};

Result i want when i create a record:

{
    uuid: 'xxx-xxx-xxx-xxx-xxx'
    created_by: 'xxx-xxx-xxx-xxx-xxx'
    name: 'Smith'
    age: 20
    ...
}

arahmanali avatar Jun 01 '18 10:06 arahmanali

We don't support inheritance at the moment, but for a long time, we have had the wish to do so (see for example https://github.com/realm/realm-java/issues/761).

kneth avatar Jun 02 '18 08:06 kneth

Hi guys. Haven't you implemented inheritance yet?

remotenode avatar Jun 16 '19 00:06 remotenode

@AwanesowArtem Sorry no, and I can't give you a timeline for it.

kneth avatar Jun 27 '19 08:06 kneth