Hello MongoDB Community !
I’m trying to adapt Realm to a Typescript project . I managed to create the schema and the classes as bellow .
Now the single issue that I have is i don’t know how to describe ‘typed’ in my class the linkingObject from Measurement that has a inverse with WorkoutSession . In a one-to-many WorkoutSession-> Measurement
I tried :
public assignee!: WorkoutSession;
No luck when i call Measurement.assignee._id
or any other property from inverse object i get undefined
.
How i should define the linkingObjects type in the class to work well with TypeScript and wekpack ?
Let me know if i should provide more info if needed.
public static schema: Realm.ObjectSchema = {
name: 'WorkoutSession',
properties: {
_id: 'string',
state: 'int',
deviceId: 'string',
activityType: { type: 'int', indexed: true },
locationType: 'int',
startDate: 'double',
endDate: 'double?',
measurments: 'Measurement[]',
},
primaryKey: '_id',
};
public static schema: Realm.ObjectSchema = {
name: 'Measurement',
properties: {
_id: 'string',
type: { type: 'string', indexed: true },
value: 'string',
time: 'double',
assignee: {
type: 'linkingObjects',
objectType: 'WorkoutSession',
property: 'measurments',
},
},
primaryKey: '_id',
};
Thanks,
Florin