Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

deserialize/serialize is not called on withRelated attributes #32

@hofp37

Description

@hofp37
// testRepository
...
    relatedAttribute: {
      type: 'relation',
      targetModel: () => modylekModel,
      relation: bookshelfRelation.createHasMany({
        foreignKey: 'testId',
      }),
    },
export const modylekModel = createModel<Modylek>({
    collectionName: 'modylek',
    adapter: getKnex,
    attributes: {
        id: { type: 'string' },
        testId: { type: 'string' },
        count: {
            type: 'number',
            deserialize: x => (x ? Number(x) : 0),
        },
    }
})
const t = await testRepository.detail({ id: '1'}, { withRelated: ['relatedAttribute'] })
// t.relatedAttribute
// { id: '1', testId: '1', count: '2' }

As a workaround had to create a repository instead just having a model

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions