Function serializable

  • Decorator that defines a new property mapping on the default model schema for the class it is used in.

    When using typescript, the decorator can also be used on fields declared as constructor arguments (using the private / protected / public keywords). The default factory will then invoke the constructor with the correct arguments as well.

    Example

    class Todo {
    @serializable(primitive())
    title // shorthand for primitves

    @serializable
    done

    constructor(title, done) {
    this.title = title
    this.done = done
    }
    }

    const json = serialize(new Todo('Test', false))
    const todo = deserialize(Todo, json)

    Parameters

    Returns ((target: any, key: string, baseDescriptor?: PropertyDescriptor) => void)

      • (target: any, key: string, baseDescriptor?: PropertyDescriptor): void
      • Parameters

        • target: any
        • key: string
        • Optional baseDescriptor: PropertyDescriptor

        Returns void

  • Parameters

    • target: any
    • key: string
    • Optional baseDescriptor: PropertyDescriptor

    Returns void

Generated using TypeDoc