Simple API wrapper that provides common operations with minimal complexity.

Constructors

Properties

Methods

  • Type Parameters

    • T = unknown

    Parameters

    • collectionName: string
    • itemId: string
    • item: T

    Returns Promise<boolean>

  • Convert an array to an indexed object for GunDB storage (public method).

    Type Parameters

    • T extends { id: string | number }

    Parameters

    • arr: T[]

      The array to convert.

    Returns Record<string, T>

    The indexed object.

  • Get a chainable wrapper for a Gun node at a given path.

    Parameters

    • path: string

      The path to the node.

    Returns {
        get: (subPath: string) => GunMessageGet<any, any>;
        map: (callback: (value: any, key: string) => any) => any;
        once: () => Promise<any>;
        put: (data: any) => Promise<GunMessagePut>;
        set: (data: any) => Promise<GunMessagePut>;
        then: () => Promise<any>;
    }

    An object with chainable methods: get, put, set, once, then, map.

  • Type Parameters

    • T = unknown

    Parameters

    • collectionName: string
    • items: Record<string, T>

    Returns Promise<boolean>

  • Get data at a given path.

    Type Parameters

    • T = unknown

    Parameters

    • path: string

      The path to retrieve data from.

    Returns Promise<null | T>

    The data at the path, or null if not found or on error.

  • Advanced user space operations

    Returns Promise<null | Record<string, unknown>>

  • Private

    Convert an indexed object back to an array. Example: { "1": {...}, "2": {...} } => [{id: '1', ...}, {id: '2', ...}]

    Type Parameters

    • T

    Parameters

    • indexedObj: null | Record<string, T>

      The indexed object to convert.

    Returns T[]

    The array.

  • Parameters

    • collectionName: string

    Returns Promise<null | Record<string, unknown>>

  • Get the current user info.

    Returns null | { pub: string; username?: string }

    The current user info, or null if not logged in.

  • Get the GunDB global node at a given path. Useful for advanced operations that need direct GunDB node access.

    Parameters

    • path: string

      The path to the global node.

    Returns any

    The Gun node.

  • Private

    Convert an array to an indexed object for GunDB storage. Example: [{id: '1', ...}, {id: '2', ...}] => { "1": {...}, "2": {...} }

    Type Parameters

    • T extends { id: string | number }

    Parameters

    • arr: T[]

      The array to convert.

    Returns Record<string, T>

    The indexed object.

  • Get the Gun node at a given path for chaining operations.

    Parameters

    • path: string

      The path to the node.

    Returns any

    The Gun node.

  • Returns Promise<null | Record<string, unknown>>

  • Returns Promise<null | Record<string, unknown>>

  • Returns Promise<null | Record<string, unknown>>

  • Get user info by alias.

    Parameters

    • alias: string

      The user alias.

    Returns Promise<null | { username: string; userPub: string }>

    The user info, or null if not found.

  • Get user data at a given path (requires login).

    Type Parameters

    • T = unknown

    Parameters

    • path: string

      The path to the user data.

    Returns Promise<null | T>

    The user data, or null if not found or on error.

  • Get the GunDB user node at a given path (requires login). Useful for advanced operations that need direct GunDB node access.

    Parameters

    • path: string

      The path to the user node.

    Returns any

    The Gun node.

    If not logged in.

  • Convert an indexed object to an array (public method).

    Type Parameters

    • T

    Parameters

    • indexedObj: null | Record<string, T>

      The indexed object to convert.

    Returns T[]

    The array.

  • Check if a user is currently logged in.

    Returns boolean

    True if logged in, false otherwise.

  • Log in a user.

    Parameters

    • username: string

      The username.

    • password: string

      The password.

    Returns Promise<null | { username: string; userPub: string }>

    The user info if successful, or null.

  • Log out the current user.

    Returns void

  • Get the Gun node at a given path for direct chaining.

    Parameters

    • path: string

      The path to the node.

    Returns any

    The Gun node.

  • Put data at a given path.

    Type Parameters

    • T = unknown

    Parameters

    • path: string

      The path to put data to.

    • data: T

      The data to put.

    Returns Promise<GunMessagePut>

    The GunMessagePut result.

  • Put user data at a given path (requires login).

    Type Parameters

    • T = unknown

    Parameters

    • path: string

      The path to put data to.

    • data: T

      The data to put.

    Returns Promise<boolean>

    True if successful, false otherwise.

  • Remove data at a given path.

    Parameters

    • path: string

      The path to remove data from.

    Returns Promise<GunMessagePut>

    The GunMessagePut result.

  • Parameters

    • collectionName: string
    • itemId: string

    Returns Promise<boolean>

  • Remove user data at a given path (requires login).

    Parameters

    • path: string

      The path to remove data from.

    Returns Promise<boolean>

    True if successful, false otherwise.

  • Parameters

    • preferences: Record<string, unknown>

    Returns Promise<boolean>

  • Parameters

    • settings: Record<string, unknown>

    Returns Promise<boolean>

  • Set data at a given path (alternative to put).

    Type Parameters

    • T = unknown

    Parameters

    • path: string

      The path to set data to.

    • data: T

      The data to set.

    Returns Promise<GunMessagePut>

    The GunMessagePut result.

  • Set user data at a given path (alternative to put, requires login).

    Type Parameters

    • T = unknown

    Parameters

    • path: string

      The path to set data to.

    • data: T

      The data to set.

    Returns Promise<boolean>

    True if successful, false otherwise.

  • Sign up a new user.

    Parameters

    • username: string

      The username.

    • password: string

      The password.

    Returns Promise<null | { username: string; userPub: string }>

    The user info if successful, or null.

  • Parameters

    • profileData: {
          avatar?: string;
          bio?: string;
          email?: string;
          name?: string;
          [key: string]: unknown;
      }

    Returns Promise<boolean>

  • Check if a user exists by alias.

    Parameters

    • alias: string

      The user alias.

    Returns Promise<boolean>

    True if the user exists, false otherwise.