idea-toolbox
    Preparing search index...

    Class User

    Table: idea_users.

    Hierarchy (View Summary)

    Index

    Constructors

    • Object initialization, setting all the default values.

      Parameters

      • OptionalnewData: any

        the data to load, optional

      • Optionaloptions: any

        custom options to apply; they will depend on the child resource

        Usually, there is no need to implement the constructor; implicitly, it will call the load of the child resource and therefore loading all the resources with default values. If needed, this is the suggested implementation:

        super();
        this.load(x);
        // ...

      Returns User

    Properties

    createdAt: number

    Timestamp of creation.

    currentTeamInProjects: { [project: string]: string }

    The currently selected team in each project.

    email: string

    === username (from Cognito, not in DynamoDB).

    userId: string

    Cognito sub.

    Methods

    • Return an attribute in a cleaned standard that force-cast the element.

      Parameters

      • origin: any

        the origin attribute, to cast

      • castFunction: (x: any) => any

        the cast function, e.g. Boolean, Number, String, x => new CustomClass(x), etc.

      • OptionaldefaultVal: any

        if set, the fallback value instead of null

      Returns any

      cleaned attribute

    • Return an array in a cleaned standard that force-cast each element, keeping only the valid ones.

      Parameters

      • origin: any[]

        the origin array, to cast and check

      • castFunction: (x: any) => any

        the cast function, e.g. x => String(x) or x => new CustomClass(x)

      • OptionaldefaultVal: any

        if set, the fallback value instead of null

      Returns any[]

      cleaned array

    • Get the current team for the user in the selected project.

      Parameters

      • project: string

      Returns string

    • Load the attributes from an already existing resource.

      Parameters

      • x: any

      Returns void

    • Load the attributes from an already existing resource and then force some attributes to assume safeData values. The function is usually used in the back-end to mix together db data with new data, without the risk of changing ids and other attributes which are managed in appositely curated scenario.

      Parameters

      • newData: any

        the data to load

      • safeData: any

        the attributes to force to specific values

      Returns void

    • Set (or reset) the current team for the user in the selected project.

      Parameters

      • project: string
      • OptionalteamId: string

      Returns void

    • Valide the object's attributes, performing all the checkings.

      Parameters

      • Optionaloptions: any

        custom options to apply; they will depend on the implementations

      Returns string[]

      errors if empty, the checkings are successfully passed.

      Typical implementation:

      const e = super.validate();
      if(this.iE(this.attr)) e.push(`attr`);
      // ...
      return e;