@rvoh/dream
    Preparing search index...

    Function DreamSerializer

    • Builds a serializer for a Dream model. A serializer is a function that takes the data to render and declares the keys to render it with:

      export const UserSerializer = (user: User) =>
      DreamSerializer(User, user).attribute('email').rendersMany('posts')

      A serializer must not read its data while being built: what it declares may not depend on its data. Dream and Psychic build it without data to read its shape (the OpenAPI schema, and the null and other-variant keys of a flattened association or customAttribute that uses it), so a serializer that reads its data while being built throws when a flattened association or customAttribute that uses it is rendered. Read the data inside a customAttribute callback, which runs only when the serializer renders, not while it is built.

      Type Parameters

      • DreamClass extends typeof Dream
      • DataType extends Dream | null
      • PassthroughDataType extends object | undefined = undefined

      Parameters

      • dreamClass: DreamClass

        The Dream model class the serializer renders

      • data: DataType

        The Dream instance to render

      • OptionalpassthroughData: PassthroughDataType

        Data available to this serializer and passed down to the serializers it renders

      Returns DreamSerializerBuilder<
          DreamClass,
          DataType,
          PassthroughDataType,
          Exclude<DataType, null>,
      >

      The serializer builder for method chaining