How to use the @orbit/data.IncorrectRelatedRecordType function in @orbit/data

To help you get started, we’ve selected a few @orbit/data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github orbitjs / orbit / packages / @orbit / record-cache / src / operation-processors / async-schema-validation-processor.ts View on Github external
record: Record,
    relationship: string,
    relatedRecord: RecordIdentity
  ) {
    const modelSchema = this._getModelSchema(record.type);
    const relationshipDef =
      modelSchema.relationships && modelSchema.relationships[relationship];
    if (relationshipDef === undefined) {
      throw new RelationshipNotFound(relationship, record.type);
    }
    const type = relationshipDef.kind
      ? relationshipDef.type
      : relationshipDef.model;
    if (Array.isArray(type)) {
      if (!type.includes(relatedRecord.type)) {
        throw new IncorrectRelatedRecordType(
          relatedRecord.type,
          relationship,
          record.type
        );
      }
    } else if (typeof type === 'string') {
      if (type !== relatedRecord.type) {
        throw new IncorrectRelatedRecordType(
          relatedRecord.type,
          relationship,
          record.type
        );
      }
    }
  }
github orbitjs / orbit / packages / @orbit / record-cache / src / operation-processors / sync-schema-validation-processor.ts View on Github external
throw new RelationshipNotFound(relationship, record.type);
    }
    const type = relationshipDef.kind
      ? relationshipDef.type
      : relationshipDef.model;
    if (Array.isArray(type)) {
      if (!type.includes(relatedRecord.type)) {
        throw new IncorrectRelatedRecordType(
          relatedRecord.type,
          relationship,
          record.type
        );
      }
    } else if (typeof type === 'string') {
      if (type !== relatedRecord.type) {
        throw new IncorrectRelatedRecordType(
          relatedRecord.type,
          relationship,
          record.type
        );
      }
    }
  }
github orbitjs / orbit / packages / @orbit / record-cache / src / operation-processors / sync-schema-validation-processor.ts View on Github external
record: Record,
    relationship: string,
    relatedRecord: RecordIdentity
  ) {
    const modelSchema = this._getModelSchema(record.type);
    const relationshipDef =
      modelSchema.relationships && modelSchema.relationships[relationship];
    if (relationshipDef === undefined) {
      throw new RelationshipNotFound(relationship, record.type);
    }
    const type = relationshipDef.kind
      ? relationshipDef.type
      : relationshipDef.model;
    if (Array.isArray(type)) {
      if (!type.includes(relatedRecord.type)) {
        throw new IncorrectRelatedRecordType(
          relatedRecord.type,
          relationship,
          record.type
        );
      }
    } else if (typeof type === 'string') {
      if (type !== relatedRecord.type) {
        throw new IncorrectRelatedRecordType(
          relatedRecord.type,
          relationship,
          record.type
        );
      }
    }
  }
github orbitjs / orbit / packages / @orbit / record-cache / src / operation-processors / async-schema-validation-processor.ts View on Github external
throw new RelationshipNotFound(relationship, record.type);
    }
    const type = relationshipDef.kind
      ? relationshipDef.type
      : relationshipDef.model;
    if (Array.isArray(type)) {
      if (!type.includes(relatedRecord.type)) {
        throw new IncorrectRelatedRecordType(
          relatedRecord.type,
          relationship,
          record.type
        );
      }
    } else if (typeof type === 'string') {
      if (type !== relatedRecord.type) {
        throw new IncorrectRelatedRecordType(
          relatedRecord.type,
          relationship,
          record.type
        );
      }
    }
  }