-
Type: Task
-
Resolution: Fixed
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
const repository = new Realm({ schema: [ { name: 'Patient', primaryKey: 'patient_id', properties: { patient_id: 'string', firstname: 'string?', regularMedications: 'RegularMedications[]', }, }, { name: 'RegularMedications', primaryKey: 'med_id', properties: { patient_id: 'string?', med_id: 'string?', medication: 'string?', }, }, ] })
Below Table insert method: (This is working)
try { repository.write(() => { let mmgo = repository.create('Patient', { patient_id: params.Patient.patient_id, firstname: params.Patient.firstname, regularMedications: [], }) params.RegularMedications.forEach(ele => { mmgo.regularMedications.push({ patient_id: params.Patient.patient_id, med_id: ele.med_id, medication: ele.medication }) }) } catch(..) {}
WHEN I USED BELOW FUNCTION only can delete specified parent_id from the "Patient" table. But Can I delete all the relation "Regulation medication" link with the "Patient" table? (tables image from realm studio: https://ibb.co/pKgMVfZ))
const query = repository.objects('Patient').filtered("patient_id = '" + fromId + "'"); repository.write(() => { repository.delete(query); });
Tables image: https://ibb.co/pKgMVfZ
**Versions:
"react-native": "0.61.5",
"realm": "^6.0.4"**