Skip to content

Commit

Permalink
fix: include vs included
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhaticus committed Nov 10, 2024
1 parent 855f1be commit bb89a84
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/serializers/serializeIncludedResourceObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import type { JSONAPIResourceObject } from '../types';

export const serializeIncludedResourceObject = <I extends object>(
classInstance: I,
included: (keyof I)[],
include: (keyof I)[],
): JSONAPIResourceObject[] => {
const relationshipTuples = getMetadataBySymbol<[keyof I, string][]>(
classInstance,
relationshipsSymbol,
);

const relationships = relationshipTuples.reduce((acc, [key]) => {
const included = relationshipTuples.filter(([key]) => include.includes(key)).reduce((acc, [key]) => {
const relatedClassInstance = classInstance[key];

if (Array.isArray(relatedClassInstance)) {
Expand All @@ -41,5 +41,5 @@ export const serializeIncludedResourceObject = <I extends object>(
);
}, [] as JSONAPIResourceObject[]);

return relationships;
return included;
};

0 comments on commit bb89a84

Please sign in to comment.