Example of of storing one to many relation data

class Parameters extends Realm.Object<Parameters> {
  param_id?: string;
  param_value?: string;
  param_name?: string;

  static primaryKey = 'param_id';

  constructor(realm: Realm) {
    super(realm, {});
  }
}
class Tags extends Realm.Object<Tags> {
  tag_name?: string;

  constructor(realm: Realm) {
    super(realm, {});
  }
}
class Contacts extends Realm.Object<Contacts> {
  id?: string;
  whatsapp_availability?: string;
  projectId?: string;
  is_subscribed?: boolean;
  candidate_id?: string;
  contact_name?: string;
  phoneNumber?: string;
  created_at?: Date;
  tags?: Realm.List<Tags> | [];
  parameters?: Realm.List<Parameters> | [];

  static primaryKey = 'id';

  constructor(realm: Realm) {
    super(realm, {});
  }
}

I have contacts array with nested objects.When i try to insert to contacts table its not automatically getting inserted to parameters array useing below fn.

realm.write(() => {
    realm.delete(realm.objects('Parameters'))
    const contact = realm.create(
      'Contacts',
      {
        whatsapp_availability: props.whatsapp_availability,
        projectId: props.projectId,
        id: props.id,
        is_subscribed: props.is_subscribed,
        candidate_id: props.candidate_id,
        contact_name: props.contact_name,
        phoneNumber: props.phoneNumber,
        created_at: new Date(props.created_at),
        parameters: props?.parameters,
        tags: props?.tags,
      },
      'modified',
    );

ALso please guide me on how to retrieve the contacts list along with respective parameters, tags array

Thanks

I have a problem

I have two realm objects:

export const BookSchema = {
  name:'Book',
  primaryKey: 'id',
  properties: {
    id: 'string',
    name: 'string',
    tags: 'Tags[]',
  },
};

export const TagSchema = {
  name:'Tags',
  primaryKey: 'id',
  properties: {
    id: 'string',
    label: 'string',
  },
};

Page1 Manage tag information

A tag is added to page2.

//  create
{
     id: 'Tags-1676464592406',
     label: 'cartoon'
}

Page 2 Information of management book

//  create
{   
     id: 'Books-1676464592406',
     label: 'web',
     tags: [{
          id: 'Tags-1676464592406',
          label: 'cartoon'
}
     ]
}

When adding a tag to tags in page1, you will be prompted

 Attempting to create an object of type 'Tags' with an existing primary key value ''Tags-1676464592406''.

What method should I use to solve the problem