Добавить ссылку с уже созданным объектом в Realm - PullRequest
0 голосов
/ 26 апреля 2020

Я пытаюсь добавить ссылку на уже созданный объект в области JS. Я уже создал много контактов, используя отдельные контакты и форму. Когда я бронирую любую услугу, мне нужно выбрать контакт и добавить ссылку на услугу с существующим контактом.

{
    name: 'Booking',
    primaryKey: 'id',
    properties: {
      id: 'string',
      client: {
        type: ContactSchema.schema.name,
      },
      service: {
        type: ServiceSchema.schema.name,
      },
      staff: {
        type: ContactSchema.schema.name,
      },
    }
}

{
    name: 'Contact',
    primaryKey: 'id',
    properties: {
      id: 'string',
      firstname: 'string',
      lastname: 'string?',
    }
}
Here i am fetching contact one contact and try to assign when i write new Booking Schema.
const someContact = realm.objects<ContactSchema>(
        ContactSchema.schema.name,
      )[0];

Я получаю сообщение об ошибке ниже.

Warning: An unhandled error was caught from submitForm() [Error: Attempting to create an object of type 'Contact' with an existing primary key value ''qj5fMw3W01587891969687''.]
Realm JS SDK Version: "realm": "^5.0.3",
Node or React Native: "react-native": "0.62.2",
Client OS & Version: MacOs Catalina
Which debugger for React Native: No Debugger
...