Home Reference Source
import User from '~/models/User.js'
public class | source

User

Implements:

Represents a User

Static Method Summary

Static Public Methods
public static

Unwraps from serach Index JSON object

public static

fromJSON(json: Object): User

Unwraps a user from an API JSON object.

Constructor Summary

Public Constructor
public

constructor(id: number, name: string, options: Object)

Creates an instance of a user locally.

Member Summary

Public Members
public get
public get
public get
public get
public get

If current user is following this one

public set

If current user is following this one

public get
public get
public get
public get

If user wants notifications

public set

If current user is following this one

Method Summary

Public Methods
public

async getSchema(): Object

Gets the schema

public

Check if is current user

public

Converts to json

Static Public Methods

public static fromIndexJSON(JSON: Object): User source

Unwraps from serach Index JSON object

Params:

NameTypeAttributeDescription
JSON Object

Search index JSON

Return:

User (nullable: true)

Created object

public static fromJSON(json: Object): User source

Unwraps a user from an API JSON object.

Params:

NameTypeAttributeDescription
json Object

User JSON object.

Return:

User (nullable: true)

User object if succesful, null if unauthorized.

Throw:

TypeError

if invalid JSON object

Public Constructors

public constructor(id: number, name: string, options: Object) source

Creates an instance of a user locally.

Params:

NameTypeAttributeDescription
id number

Integer uniquely id'ing user.

name string

user display name

options Object

other options

options.avatar string
  • nullable: true

avatar URL

options.isFollowing boolean

If current user is following

options.isAdmin boolean

If user is admin

options.receiveNotifications boolean

If user wants notifications

Public Members

public get answerCount: number source

public get avatar: string source

public get id: number source

public get isAdmin: boolean source

public get isFollowing: boolean source

If current user is following this one

public set isFollowing: boolean source

If current user is following this one

public get name: string source

public get postCount: number source

public get profilePage: string source

public get receiveNotifications: boolean source

If user wants notifications

public set receiveNotifications: boolean source

If current user is following this one

Public Methods

public async getSchema(): Object source

Gets the schema

Return:

Object

public isMe(): boolean source

Check if is current user

Return:

boolean

public toJSON(): Object source

Converts to json

Return:

Object

json object