node-json-db
    Preparing search index...

    Class JsonDB

    Index

    Constructors

    Methods

    • Returns the number of element which constitutes the array

      Parameters

      • dataPath: string

      Returns Promise<number>

    • Delete the data

      Parameters

      • dataPath: string

        path leading to the data

      Returns Promise<void>

    • Check for existing datapath

      Parameters

      • dataPath: string

      Returns Promise<boolean>

    • Find all specific entry in an array/object

      Type Parameters

      • T

      Parameters

      • rootPath: string

        base dataPath from where to start searching

      • callback: FindCallback

        method to filter the result and find the wanted entry. Receive the entry and it's index.

      Returns Promise<T[] | undefined>

    • Find a specific entry in an array/object

      Type Parameters

      • T

      Parameters

      • rootPath: string

        base dataPath from where to start searching

      • callback: FindCallback

        method to filter the result and find the wanted entry. Receive the entry and it's index.

      Returns Promise<T | undefined>

    • Convert a router style path to a normal path By default propertyName to search is "id"

      Parameters

      • path: string

        router based path to a correct base path

      • propertyName: string = 'id'

        name of the property to look for searchValue

      Returns Promise<string>

    • Get the wanted data

      Parameters

      • dataPath: string

        path of the data to retrieve

      Returns Promise<any>

    • Returns the index of the object that meets the criteria submitted. Returns -1, if no match is found.

      Parameters

      • dataPath: string

        base dataPath from where to start searching

      • searchValue: string | number

        value to look for in the dataPath

      • propertyName: string = 'id'

        name of the property to look for searchValue

      Returns Promise<number>

    • Return the index of the value inside the array. Returns -1, if no match is found.

      Parameters

      • dataPath: string

        base dataPath from where to start searching

      • searchValue: string | number

        value to look for in the dataPath

      Returns Promise<number>

    • Same as getData only here it's directly typed to your object

      Type Parameters

      • T

      Parameters

      • dataPath: string

        path of the data to retrieve

      Returns Promise<T>

    • Same as getData but with your own object type and a possible default value when we can't find the data path

      Type Parameters

      • T

      Parameters

      • dataPath: string

        path of the data to retrieve

      • OptionaldefaultValue: T

        value to use when the dataPath doesn't lead to data

      Returns Promise<T>

    • Manually load the database It is automatically called when the first getData is done

      Returns Promise<void>

    • Pushing data into the database

      Parameters

      • dataPath: string

        path leading to the data

      • data: any

        data to push

      • override: boolean = true

        overriding or not the data, if not, it will merge them

      Returns Promise<void>

    • Reload the database from the file

      Returns Promise<void>

    • Only use this if you know what you're doing. It reset the full data of the database.

      Parameters

      • data: any

      Returns void

    • Manually save the database By default you can't save the database if it's not loaded

      Parameters

      • Optionalforce: boolean

        force the save of the database

      Returns Promise<void>