Options
All
  • Public
  • Public/Protected
  • All
Menu

Class default<T>

description

Class DataStore to save Object JS file as key:value

version

1.0

Type parameters

  • T

Hierarchy

  • default

Implements

Index

Constructors

constructor

Properties

Protected algorithm

algorithm: string

Protected Optional cryptography

cryptography: undefined | Cryptography

Protected encrypt

encrypt: boolean

Protected fileName

fileName: string

Protected overwrite

overwrite: boolean

Protected readFile

readFile: { (path: PathLike | number, options?: { encoding?: null; flag?: string } | null): Buffer; (path: PathLike | number, options: { encoding: BufferEncoding; flag?: string } | BufferEncoding): string; (path: PathLike | number, options?: (BaseEncodingOptions & { flag?: string }) | BufferEncoding | null): string | Buffer }

Type declaration

    • (path: PathLike | number, options?: { encoding?: null; flag?: string } | null): Buffer
    • (path: PathLike | number, options: { encoding: BufferEncoding; flag?: string } | BufferEncoding): string
    • (path: PathLike | number, options?: (BaseEncodingOptions & { flag?: string }) | BufferEncoding | null): string | Buffer
    • Synchronously reads the entire contents of a file.

      Parameters

      • path: PathLike | number

        A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. If a file descriptor is provided, the underlying file will not be closed automatically.

      • Optional options: { encoding?: null; flag?: string } | null

        An object that may contain an optional flag. If a flag is not provided, it defaults to 'r'.

      Returns Buffer

    • Synchronously reads the entire contents of a file.

      Parameters

      • path: PathLike | number

        A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. If a file descriptor is provided, the underlying file will not be closed automatically.

      • options: { encoding: BufferEncoding; flag?: string } | BufferEncoding

        Either the encoding for the result, or an object that contains the encoding and an optional flag. If a flag is not provided, it defaults to 'r'.

      Returns string

    • Synchronously reads the entire contents of a file.

      Parameters

      • path: PathLike | number

        A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. If a file descriptor is provided, the underlying file will not be closed automatically.

      • Optional options: (BaseEncodingOptions & { flag?: string }) | BufferEncoding | null

        Either the encoding for the result, or an object that contains the encoding and an optional flag. If a flag is not provided, it defaults to 'r'.

      Returns string | Buffer

Protected schema

schema: T

Protected writeFile

writeFile: (path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions) => void

Type declaration

    • (path: PathLike | number, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void
    • Synchronously writes data to a file, replacing the file if it already exists.

      Parameters

      • path: PathLike | number

        A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. If a file descriptor is provided, the underlying file will not be closed automatically.

      • data: string | NodeJS.ArrayBufferView

        The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.

      • Optional options: WriteFileOptions

        Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. If encoding is not supplied, the default of 'utf8' is used. If mode is not supplied, the default of 0o666 is used. If mode is a string, it is parsed as an octal integer. If flag is not supplied, the default of 'w' is used.

      Returns void

Methods

decryptData

  • decryptData(data: DataRaw): Buffer

encryptData

  • encryptData(data: DataRaw): Buffer

getFileName

  • getFileName(): string

getSecret

  • getSecret(): string

read

  • read<P>(key: P): T[P]
  • Read data in file (with encryption if active)

    throws

    DataStoreException

    method

    Type parameters

    • P: string | number | symbol

    Parameters

    • key: P

      The key name declared at schema)

    Returns T[P]

    depends of schema

Private readFromFile

  • readFromFile(): T

write

  • write(payload: any): void
  • Write data in file (with encryption if active)

    throws

    DataStoreException

    method

    Parameters

    • payload: any

      The data to write (must be a object declared at schema)

    Returns void

    void

Generated using TypeDoc