From 4627d9b91917cbf93b7b282adf57b6a73c927327 Mon Sep 17 00:00:00 2001 From: Gerold Penz Date: Mon, 23 Sep 2024 21:56:39 +0200 Subject: [PATCH] API-Docs --- README.md | 1 + docs/{api => }/.nojekyll | 0 docs/api/assets/navigation.js | 1 - docs/api/assets/search.js | 1 - docs/api/classes/BunSqliteKeyValue.html | 111 -------- docs/api/modules.html | 2 - docs/{api => }/assets/highlight.css | 0 docs/{api => }/assets/icons.js | 0 docs/{api => }/assets/icons.svg | 0 docs/{api => }/assets/main.js | 0 docs/assets/navigation.js | 1 + docs/assets/search.js | 1 + docs/{api => }/assets/style.css | 0 docs/classes/index.BunSqliteKeyValue.html | 143 +++++++++++ docs/{api => }/index.html | 27 +- docs/interfaces/interfaces.Item.html | 2 + docs/interfaces/interfaces.Options.html | 16 ++ docs/interfaces/interfaces.Record.html | 2 + docs/modules/index.html | 7 + docs/modules/interfaces.html | 9 + docs/types/interfaces.Field.html | 2 + docs/types/interfaces.Key.html | 2 + docs/types/interfaces.MaxExpiringItems.html | 5 + docs/types/interfaces.Tag.html | 2 + docs/types/interfaces.TtlMs.html | 6 + .../index.INDEX_OUT_OF_RANGE_ERROR_LABEL.html | 2 + .../index.INVALID_COUNT_ERROR_LABEL.html | 2 + docs/variables/index.ITEM_NOT_EXISTS.html | 2 + .../index.ITEM_NOT_EXISTS_ERROR_LABEL.html | 2 + .../variables/index.NO_ARRAY_ERROR_LABEL.html | 2 + package.json | 2 +- src/index.ts | 239 ++++++++++++++---- tests/memory.test.ts | 26 +- typedoc.json | 16 +- 34 files changed, 449 insertions(+), 185 deletions(-) rename docs/{api => }/.nojekyll (100%) delete mode 100644 docs/api/assets/navigation.js delete mode 100644 docs/api/assets/search.js delete mode 100644 docs/api/classes/BunSqliteKeyValue.html delete mode 100644 docs/api/modules.html rename docs/{api => }/assets/highlight.css (100%) rename docs/{api => }/assets/icons.js (100%) rename docs/{api => }/assets/icons.svg (100%) rename docs/{api => }/assets/main.js (100%) create mode 100644 docs/assets/navigation.js create mode 100644 docs/assets/search.js rename docs/{api => }/assets/style.css (100%) create mode 100644 docs/classes/index.BunSqliteKeyValue.html rename docs/{api => }/index.html (99%) create mode 100644 docs/interfaces/interfaces.Item.html create mode 100644 docs/interfaces/interfaces.Options.html create mode 100644 docs/interfaces/interfaces.Record.html create mode 100644 docs/modules/index.html create mode 100644 docs/modules/interfaces.html create mode 100644 docs/types/interfaces.Field.html create mode 100644 docs/types/interfaces.Key.html create mode 100644 docs/types/interfaces.MaxExpiringItems.html create mode 100644 docs/types/interfaces.Tag.html create mode 100644 docs/types/interfaces.TtlMs.html create mode 100644 docs/variables/index.INDEX_OUT_OF_RANGE_ERROR_LABEL.html create mode 100644 docs/variables/index.INVALID_COUNT_ERROR_LABEL.html create mode 100644 docs/variables/index.ITEM_NOT_EXISTS.html create mode 100644 docs/variables/index.ITEM_NOT_EXISTS_ERROR_LABEL.html create mode 100644 docs/variables/index.NO_ARRAY_ERROR_LABEL.html diff --git a/README.md b/README.md index 222ece4..6f6e052 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ The ideas for the implementation come from - `rPop()` --> Returns elements at the end of the list and removes them. - `lIndex()` --> Returns the element at the specified index of the list. - `lLen()` --> Returns the length of the list. + - `lSet()` --> Updates the element at the specified index of the list. - Tags (Labels) - `addTag()` --> Adds a tag to an item. - `deleteTag()` --> Deletes a tag of an item. diff --git a/docs/api/.nojekyll b/docs/.nojekyll similarity index 100% rename from docs/api/.nojekyll rename to docs/.nojekyll diff --git a/docs/api/assets/navigation.js b/docs/api/assets/navigation.js deleted file mode 100644 index 2e32912..0000000 --- a/docs/api/assets/navigation.js +++ /dev/null @@ -1 +0,0 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA4uuVipJrShRslJyKs0LLszJLEn1Tq0MS8wpTVXSUSpILMlQslJKzkksLk4t1sdQopdRkpujpKOUnZmXomRlaGRRGwsAijsZtlEAAAA=" \ No newline at end of file diff --git a/docs/api/assets/search.js b/docs/api/assets/search.js deleted file mode 100644 index c52ba94..0000000 --- a/docs/api/assets/search.js +++ /dev/null @@ -1 +0,0 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA+1bS5PjuJH+L/RlDzCbeAN1XNvhmPAeHLEbc+ntmGBLrBLdepmiqqa3o//7RuLBIiAmRUkVPvlUWRSYmUjk40MC/FF0h7dT8fT5R/Gt3a+LJ8oMKfb1rimeiv887//7n9u2b/7WfP+13p6bghTnbls8FattfTo1p08XI8pNv9sWJA4onoriJ4m8WSXema+bbdM3f/n92HbNeiHjP+QvjcSQ4lh3zb6f1HtWh9uEPy51tW3qbqnQOPhhmYfT4onGwQ/KfGn6Px3O+36p2NH4D5L8a71tF/tW/tKDOpya/pe+2Z2Wih+Nv10yrZgYJG/+1nxfLDYOvl2mkpKrQehvv/Xfj4s9zEkth3cWCi+9sojBN39tejds+dzHbzxq9F/r7XLBYfC/2OggNRj9j+wWszt1MbP/+aYk+j78wfja/LJfLc6icfCjMv/c3CAzDH5Q5vbv59Nmqcw4+EGZ3S0yu4+Ruf374bh8mm7sw7NcLrH7EInbX/br5vfFs4yjH5X6X81+sUw/9kGJ9Xr9P/XLUpnD6A9BczcIHr/wUbIX14DkjY+S/tKsbwIdUy8u1uULKVrnoU8/itemO7WHffFUsJKXtiDFc9ts17Cz8EqSYnXY7RqH7taH1dmRX8KwX5tVf+hgsB/9qSrI54qwqhScfvlCPseX3Q+U0FIbRRjhpRCccCJKoTQRhJZMCCIJLY2VRBFWCi6IDn8NYSXlgtjwP60CA0ojwQgtKZOE8vhEEFYaGCzjE+UJp1acidPLPXHqU9BSE2ZKW4lEf/cLKCIUI9QSWlrDCANNqGKEUZiLzpjThDnzLKgsLU2NwyJzpgxhjIiSMkoYB3swRZggvOSWESbjGEVoWVlDmI6E8W+lCrBEAV6Qz8xOzY5HBSRVMDtWViBX+icpT57wFAX5zCvCeKmtTHjCL4bwslJhfTijhIPBONOEU+BdScIZLJTUhIM7VIISLiIhPZHK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nBwgMDTzEuLkRrxrt2OwhF+3ys3hzu/WOh1N7kTok6m1Xffd4OJ3ar2mSRNmhwX7ZfECRztXM09XtKdtCWXTHgjoJ3ClOsvX9Rx5dszp0WXm8/6DCc0uxOArlcCbPTdfsV80nwE2nTxeIxqKeNcNzd3jNDvowLnEneNW9uua4rVeX1yiw1UD9vmv6c5fdIYPvrJbVu+uY0PNPZ48hqSvtl4crVte+bDIwjBZ2PIwuunSjy03Dgs1jy8v+mxifFOhFTE7N6pC11/TtByCntL2PfnCD2uPU9Beb4NF9mGLpZCYP4u5PLqfmtenqpMWPNh8XcNsknQP0Ch9aqU677OMPhU0NN/Qhdbvb75udjs2qfW6zYEch6PUsdHmtGVMq/UJigcH7uuuz3iN8M3vzlPtDekg4myCXaXbomvL9vO8//jdvsVAU+Czmvjs1/RTj+8ujY5xW7qVfsN3eCDidj+nOYPbDmSkOFx9uofvLq1nf3yFNL02huAdtxF1eHEU1QpNAX7fpmSN6WRt36L7+ln4yOPu5HMYhzdbYTHAWm/TDHCwug6OEuj7DLr3bvex45qO3aIt7vv0ma4rfX6X6TfZhAXpdFXfMdpcmOMx6uPmTwoKeBMpZs6dfjU6K6c7ZTUM0my2+aQgf0J5WXXvMDtXu/9jgvF83z/lHFRT98m9Ze2VSULbwmBPNgWKEbwYKb/9w7ZxvFLGVQjm8mnSpb34/v+GFfoqC7p1f82+kZo9OZjwaLXMTF37ub+++Nl1S7NGd5nVWbynuRW/0ohnurU63lehl9GvXi9+y63Doxnd53Lxt8kOG+ePkuQV8a9NjGyxSFoPDt8M5vXSMtujRbPzWtX2fTbG6H1B+z+5v3nzj7/vhnOSpJT3eKT7/13TZBubGz2G/kOLYHpttu2+Kp89ffv78f/mq6jndZgAA"; \ No newline at end of file diff --git a/docs/api/classes/BunSqliteKeyValue.html b/docs/api/classes/BunSqliteKeyValue.html deleted file mode 100644 index 2cdf46f..0000000 --- a/docs/api/classes/BunSqliteKeyValue.html +++ /dev/null @@ -1,111 +0,0 @@ -BunSqliteKeyValue | Bun SQlite Key Value

A super fast key-value store with SQLite that uses bun:sqlite -and v8 as a fast JSON replacement.

-

Properties

hKeys: ((key: string) => undefined | string[]) = ...

Alias for hGetFields()

-
hVals: (<T>(key: string) => undefined | T[]) = ...

Alias for hGetValues()

-

Type declaration

    • <T>(key): undefined | T[]
    • Returns the values contained in the hash stored at key.

      -

      Use hmGet() to read field names and values.

      -

      Do not use the hash functions with several very large amounts of data or blobs. -This is because the entire data record with all fields is always read and written. -It is better to use setValues() and getValues() for large amounts of data.

      -

      Inspired by: https://docs.keydb.dev/docs/commands/#hvals

      -

      Type Parameters

      • T = any

      Parameters

      • key: string

      Returns undefined | T[]

      If the data record (marked with key) does not exist, undefined is returned.

      -
      import { BunSqliteKeyValue } from "bun-sqlite-key-value"

      const store = new BunSqliteKeyValue()

      store.hmSet("key-1", {
      "field-1": "value-1",
      "field-2": "value-2"
      })
      store.hGetValues("key-1") // --> ["value-1", "value-2"] -
      - -

Methods

  • Adds a tag to an item.

    -

    Raises an error if the item key does not exist.

    -

    Parameters

    • key: string
    • tag: string

    Returns boolean

    Returns true if the tag has been added. -Returns false if the tag already exists.

    -
  • Delete all items

    -

    Returns void

  • Close database

    -

    Removes .sqlite-shm and .sqlite-wal files

    -

    Returns void

  • Delete all expired records

    -

    Returns void

  • Deletes a tag of an item.

    -

    Parameters

    • key: string
    • tag: string

    Returns boolean

    Returns true if the tag has been deleted. -Returns false if the tag or the item does not exist.

    -
  • Deletes tagged items.

    -

    Parameters

    • tag: string

    Returns void

  • Deletes multiple tags or all tags of the item.

    -

    Parameters

    • key: string
    • Optionaltags: string[]

      Deletes all tags within the array. -If undefined, all tags of the item are deleted.

      -

    Returns void

  • Returns the number of all items in the database, including those that have already expired.

    -

    Use getCountValid() if you want to get the number of items that have not yet expired.

    -

    Returns number

  • Returns the number of all valid (non-expired) items in the database.

    -

    Use getCount() if you want the fastet possible method.

    -

    Parameters

    • OptionaldeleteExpired: boolean

    Returns number

  • Hash function: Delete a field of the map object.

    -

    Inspired by: https://docs.keydb.dev/docs/commands/#hdel

    -

    Parameters

    • key: string

      The key of the item.

      -
    • field: string

      The name of the field.

      -

    Returns undefined | boolean

      -
    • undefined if the key does not exist.
    • -
    • true if the field existed and was deleted.
    • -
    • false if the field did not exist.
    • -
    -
  • Returns the values contained in the hash stored at key.

    -

    Use hmGet() to read field names and values.

    -

    Do not use the hash functions with several very large amounts of data or blobs. -This is because the entire data record with all fields is always read and written. -It is better to use setValues() and getValues() for large amounts of data.

    -

    Inspired by: https://docs.keydb.dev/docs/commands/#hvals

    -

    Type Parameters

    • T = any

    Parameters

    • key: string

    Returns undefined | T[]

    If the data record (marked with key) does not exist, undefined is returned.

    -
    import { BunSqliteKeyValue } from "bun-sqlite-key-value"

    const store = new BunSqliteKeyValue()

    store.hmSet("key-1", {
    "field-1": "value-1",
    "field-2": "value-2"
    })
    store.hGetValues("key-1") // --> ["value-1", "value-2"] -
    - -
  • Returns the element at index in the list stored at key.

    -

    The index is zero-based, so 0 means the first element, 1 the second element and so on. -Negative indices can be used to designate elements starting at the tail of the list. -Here, -1 means the last element, -2 means the penultimate and so forth.

    -

    Inspired by: https://docs.keydb.dev/docs/commands/#lindex

    -

    Type Parameters

    • T = any

    Parameters

    • key: string
    • index: number

    Returns undefined | T

    When the value at key is not a list, an error is returned.

    -
  • Returns the length of the list stored at key.

    -

    If key does not exist, it is interpreted as an empty list and 0 is returned. -An error is returned when the value stored at key is not an array. --> Array.isArray()

    -

    Inspired by: https://www.dragonflydb.io/docs/command-reference/lists/llen

    -

    Parameters

    • key: string

    Returns number

    The length of the list at key.

    -
  • Removes and returns the first element of the list stored at key. -If count is specified, returns count number of elements.

    -

    Inspired by: https://docs.keydb.dev/docs/commands/#lpop

    -

    Type Parameters

    • T = any

    Parameters

    • key: string
    • Optionalcount: number

    Returns undefined | T | T[]

    If count is undefined, it returns the first element of the list stored at key. -If count is a positive number, it returns the first count elements of the list stored at key. -Returns undefined if key was not found or the array is empty.

    -
  • Removes and returns the last element of the list stored at key. -If count is specified, returns count number of elements.

    -

    Inspired by: https://docs.keydb.dev/docs/commands/#rpop

    -

    Type Parameters

    • T = any

    Parameters

    • key: string
    • Optionalcount: number

    Returns undefined | T | T[]

    If count is undefined, it returns the last element of the list stored at key. -If count is a positive number, it returns the last count elements of the list stored at key. -Returns undefined if key was not found or the array is empty.

    -
  • Adds a large number of entries to the database and takes only a small fraction -of the time that set() would take individually.

    -

    Type Parameters

    • T = any

    Parameters

    • items: {
          key: undefined | string;
          ttlMs?: TtlMs;
          value: T;
      }[]

    Returns void

diff --git a/docs/api/modules.html b/docs/api/modules.html deleted file mode 100644 index 517f3d4..0000000 --- a/docs/api/modules.html +++ /dev/null @@ -1,2 +0,0 @@ -Bun SQlite Key Value

Bun SQlite Key Value

Index

Classes

diff --git a/docs/api/assets/highlight.css b/docs/assets/highlight.css similarity index 100% rename from docs/api/assets/highlight.css rename to docs/assets/highlight.css diff --git a/docs/api/assets/icons.js b/docs/assets/icons.js similarity index 100% rename from docs/api/assets/icons.js rename to docs/assets/icons.js diff --git a/docs/api/assets/icons.svg b/docs/assets/icons.svg similarity index 100% rename from docs/api/assets/icons.svg rename to docs/assets/icons.svg diff --git a/docs/api/assets/main.js b/docs/assets/main.js similarity index 100% rename from docs/api/assets/main.js rename to docs/assets/main.js diff --git a/docs/assets/navigation.js b/docs/assets/navigation.js new file mode 100644 index 0000000..20f1abd --- /dev/null +++ b/docs/assets/navigation.js @@ -0,0 +1 @@ +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA43SXW+CMBQG4P9yrsk2XdwHdzjrQlRIEI2LMU1Hz7RZRQZ1gSz+90Xd5EMt3NL3PG9bOv8BhakCE0TIMQUDIqZWYMJ6w7cSk9vD55uVWksw4FOEHMy2AcFKSB5jCOb8BHS34fhLCoUDzKZMbjHHAsmS5ISdBct8q/20M06q7fTIjLoTn7p96lnOK6HE81yPDq0uGeYV3ywW7D3fsX6u3HjfLhVOraHdoy/uxPGbdl0Z0dX4ZEQd16dkZo/9sQYvB6ukcbxcMIFjFGPAFHK43tPwQNeHNEdyXGp5nvXWrONS+gxfFHgRKow/WIDJpVf6v9boqdoK1zmSDxedfaaCdR4K23EjJTZhUsf8xXSSh8Em5nXQMaVz+gJlgVFZVBYO6xXg7vmx1Sn+xAFmGmKAWR0wYilJIxGLcLm/wkSjVaN1tM+WGs1ny1pAyZFuQ4f1y8hit/gFveAXyCwFAAA=" \ No newline at end of file diff --git a/docs/assets/search.js b/docs/assets/search.js new file mode 100644 index 0000000..ec46c3e --- /dev/null +++ b/docs/assets/search.js @@ -0,0 +1 @@ +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA809XZPjtpH/RXm5B5aW+CKAfXNiJ7dlx07ZjitXe64pzYgzo1hfJ1Gz3rj836+6G6AIkE1RM6pKnoQhie5Go9Hf5Pw2O+w+HWfvP/42+2W1Xc7ey2K2XWzq2fvZarusf50Vs9NhPXs/2+yWp3V9fIdX58/NZj0rZg/rxfFYH2fvZ7PfiwhBnUF8+PanL7758OXdn777+7c/3n31/ffffX/3zRd//OqbFuzL4rBa3J8BszMGUBaz/eJQb5uW1kEavv3u7ovvv//ifyahH3r41Zg//PjVX+++/e7Hu6/+8eGHH3+Ytn5+zq3omIr79fi+/fKrf9x99/cf77778933X3z7l68mbv3YtOuoEdK15PzxtP3h/9arpv66/vzTYn2qWwoCrIC/99x1KGWpzziX9bpu6q9+3a8O9fIqfH/Ip45g74MYp+c1hNyKgod1vThcR0CcciP8u+OVDIhTboL/qW7+tDttm+tI6My6KRU/LdarK+Uyn3oTeo5186GpN8frSOnMugkVzz/UV+5LmHEb7H+5Gvtfboh9c/3iN7dc/eb65W9uuf7/Xhz/vKrXV56G7rSbScErFER32s3owIVdeSaTeTejBB94BSXtvNtQ8uUrzOd50m1o+LB9uNJ+xim34sHV+MOUm+Bf/+10fL4Of5xyE/yH6/Efbol//bfd/trl44wbrf5a7IcbYl9/SELRaauPc25DwTf19kr8NOM22K820esbWujF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t4udZ/SsJyNBflY+dMiTdCx7+HkR4Y3Z5+yN71Zqqarmk/Pee50/COa13zM+tNqnZkAVnmw7u6nVdrtx3r0jGxf9B3YE/ppd0pfIPZsZob1knuJesE2hrSER6eWF6zDqmmyFxrZ3vepnzC/7Dt8zj5CMf4ezyCE3SmBwPJz8oH4V33Isknjn5vuwfi5mO1X+3q92taz9x9//v33/wd9OtT+X6kAAA=="; \ No newline at end of file diff --git a/docs/api/assets/style.css b/docs/assets/style.css similarity index 100% rename from docs/api/assets/style.css rename to docs/assets/style.css diff --git a/docs/classes/index.BunSqliteKeyValue.html b/docs/classes/index.BunSqliteKeyValue.html new file mode 100644 index 0000000..cebd306 --- /dev/null +++ b/docs/classes/index.BunSqliteKeyValue.html @@ -0,0 +1,143 @@ +BunSqliteKeyValue | Bun SQlite Key Value

A super fast key-value store with SQLite that uses bun:sqlite +and v8 as a fast JSON replacement.

+

Hash (Map Object)

  • Hash function: Deletes a field of the map object.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#hdel

    +

    Parameters

    • key: string

      The key of the item.

      +
    • field: string

      The name of the field.

      +

    Returns undefined | boolean

      +
    • undefined if the key does not exist.
    • +
    • true if the field existed and was deleted.
    • +
    • false if the field did not exist.
    • +
    +
  • Hash (Map Object) - Read Value

    +

    Do not use it with several very large amounts of data or blobs. +This is because the entire data record with all fields is always read and written.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#hget

    +

    Type Parameters

    • T = any

    Parameters

    • key: string
    • field: string

    Returns undefined | T

  • Returns the values contained in the hash stored at key.

    +

    Use hmGet() to read field names and values.

    +

    Do not use the hash functions with several very large amounts of data or blobs. +This is because the entire data record with all fields is always read and written. +It is better to use setValues() and getValues() for large amounts of data.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#hvals

    +

    Type Parameters

    • T = any

    Parameters

    • key: string

    Returns undefined | T[]

    If the data record (marked with key) does not exist, undefined is returned.

    +
    import { BunSqliteKeyValue } from "bun-sqlite-key-value"

    const store = new BunSqliteKeyValue()

    store.hmSet("key-1", {
    "field-1": "value-1",
    "field-2": "value-2"
    })
    store.hGetValues("key-1") // --> ["value-1", "value-2"] +
    + +
  • Hash (Map Object) - Has Field

    +

    Returns if field is an existing field in the hash stored at key.

    +

    Do not use it with several very large amounts of data or blobs. +This is because the entire data record with all fields is always read.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#hexists

    +

    Parameters

    • key: string
    • field: string

    Returns undefined | boolean

  • Hash (Map Object) - Read Multiple Values

    +

    Do not use it with several very large amounts of data or blobs. +This is because the entire data record with all fields is always read and written.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#hmget

    +

    Type Parameters

    • T = any

    Parameters

    • key: string
    • Optionalfields: string[]

    Returns undefined | {
        [field: Field]: T | undefined;
    }

  • Hash (Map Object) - Write Multiple Values

    +

    Do not use it with several very large amounts of data or blobs. +This is because the entire data record with all fields is always read and written.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#hmset

    +

    Type Parameters

    • T = any

    Parameters

    • key: string
    • fields: {
          [field: Field]: T;
      }
    • OptionalttlMs: TtlMs

    Returns void

  • Hash (Map Object) - Write Value

    +

    Do not use it with several very large amounts of data or blobs. +This is because the entire data record with all fields is always read and written.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#hset

    +

    Type Parameters

    • T = any

    Parameters

    • key: string
    • field: string
    • value: T
    • OptionalttlMs: TtlMs

    Returns boolean

List (Array Object)

  • Returns the element at index in the list stored at key.

    +

    The index is zero-based, so 0 means the first element, 1 the second element and so on. +Negative indices can be used to designate elements starting at the tail of the list. +Here, -1 means the last element, -2 means the penultimate and so forth.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#lindex

    +

    Type Parameters

    • T = any

    Parameters

    • key: string
    • index: number

    Returns undefined | T

    When the value at key is not a list, an error is returned.

    +
  • Returns the length of the list stored at key.

    +

    If key does not exist, it is interpreted as an empty list and 0 is returned. +An error is returned when the value stored at key is not an array. --> Array.isArray()

    +

    Inspired by: https://www.dragonflydb.io/docs/command-reference/lists/llen

    +

    Parameters

    • key: string

    Returns number

    The length of the list at key.

    +
  • Removes and returns the first element of the list stored at key. +If count is specified, returns count number of elements.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#lpop

    +

    Type Parameters

    • T = any

    Parameters

    • key: string
    • Optionalcount: number

    Returns undefined | T | T[]

    If count is undefined, it returns the first element of the list stored at key. +If count is a positive number, it returns the first count elements of the list stored at key. +Returns undefined if key was not found or the array is empty.

    +
  • Updates the list element at index to value.

    +

    For more information on the index argument, see lIndex().

    +

    An error is returned if the key does not exist. +An error is returned when the value stored at key is not an array. +An error is returned for out of range indexes.

    +

    Inspired by: https://www.dragonflydb.io/docs/command-reference/lists/lset

    +

    Type Parameters

    • T = any

    Parameters

    • key: string
    • index: number
    • value: T

    Returns true

    true if the key exists and the value has been set.

    +
  • Removes and returns the last element of the list stored at key. +If count is specified, returns count number of elements.

    +

    Inspired by: https://docs.keydb.dev/docs/commands/#rpop

    +

    Type Parameters

    • T = any

    Parameters

    • key: string
    • Optionalcount: number

    Returns undefined | T | T[]

    If count is undefined, it returns the last element of the list stored at key. +If count is a positive number, it returns the last count elements of the list stored at key. +Returns undefined if key was not found or the array is empty.

    +

Other

  • Deletes all items

    +

    Returns void

  • Close database

    +

    Removes .sqlite-shm and .sqlite-wal files

    +

    Returns void

  • Deletes all expired records.

    +

    Returns void

  • Returns the number of all items in the database, including those that have already expired.

    +

    Use getCountValid() if you want to get the number of items that have not yet expired.

    +

    Returns number

  • Returns the number of all valid (non-expired) items in the database.

    +

    Use getCount() if you want the fastet possible method.

    +

    Parameters

    • OptionaldeleteExpired: boolean

    Returns number

  • Adds a large number of entries to the database and takes only a small fraction +of the time that set() would take individually.

    +

    Type Parameters

    • T = any

    Parameters

    • items: {
          key: undefined | string;
          ttlMs?: TtlMs;
          value: T;
      }[]

    Returns void

Tags (Labels)

  • Adds a tag to an item.

    +

    Raises an error if the item key does not exist.

    +

    Parameters

    • key: string
    • tag: string

    Returns boolean

    Returns true if the tag has been added. +Returns false if the tag already exists.

    +
  • Deletes a tag of an item.

    +

    Parameters

    • key: string
    • tag: string

    Returns boolean

    Returns true if the tag has been deleted. +Returns false if the tag or the item does not exist.

    +
  • Deletes tagged items.

    +

    Parameters

    • tag: string

    Returns void

  • Deletes multiple tags or all tags of the item.

    +

    Parameters

    • key: string
    • Optionaltags: string[]

      Deletes all tags within the array. +If undefined, all tags of the item are deleted.

      +

    Returns void

  • Returns tagged items.

    +

    Type Parameters

    • T

    Parameters

    • tag: string

    Returns undefined | Item<T>[]

  • Returns tagged keys.

    +

    Parameters

    • tag: string

    Returns undefined | string[]

  • Returns tagged values.

    +

    Type Parameters

    • T = any

    Parameters

    • tag: string

    Returns undefined | (undefined | T)[]

diff --git a/docs/api/index.html b/docs/index.html similarity index 99% rename from docs/api/index.html rename to docs/index.html index a2b508a..f4ca1a9 100644 --- a/docs/api/index.html +++ b/docs/index.html @@ -107,6 +107,7 @@
  • rPop() --> Returns elements at the end of the list and removes them.
  • lIndex() --> Returns the element at the specified index of the list.
  • lLen() --> Returns the length of the list.
  • +
  • lSet() --> Updates the element at the specified index of the list.
  • Tags (Labels) @@ -151,7 +152,7 @@

    readwrite?: boolean: Open the database as read-write (default: true).

    ttlMs?: boolean: -Default time span in milliseconds before an entry +Default time span in milliseconds before an item written to the DB becomes invalid and is marked for deletion.

    maxExpiringItemsInDb?: number: Default value that specifies the maximum number of @@ -222,7 +223,7 @@ A search for "language:" would return all languages.

    string[]: Array with keys. The returned array is exactly the same size as the passed array. -Entries that are not found are returned as undefined. +Items that are not found are returned as undefined. Only exact matches with the keys are returned.

    import { BunSqliteKeyValue } from "bun-sqlite-key-value"

    const store = new BunSqliteKeyValue()

    store.set("language:de", "German")
    store.set("language:en", "English")
    store.set("language:it", "Italian")

    store.getValues() // --> [ "German", "English", "Italian" ]
    store.getValues("language:") // --> [ "German", "English", "Italian" ]

    store.values // --> [ "German", "English", "Italian" ]
    @@ -256,7 +257,7 @@ A search for "language:" would return all languages.

    string[]: Array with keys. The returned array is exactly the same size as the passed array. -Entries that are not found are returned as undefined. +Items that are not found are returned as undefined. Only exact matches with the keys are returned.

    import { BunSqliteKeyValue } from "bun-sqlite-key-value"

    const store = new BunSqliteKeyValue()

    store.set("language:de", "German")
    store.set("language:en", "English")
    store.set("language:it", "Italian")

    store.getItems("language:") // --> [
    // {key: "language:de", value: "German"},
    // {key: "language:en", value: "English"},
    // {key: "language:it", value: "Italian"}
    // ]

    store.items // --> [
    // {key: "language:de", value: "German"},
    // {key: "language:en", value: "English"},
    // {key: "language:it", value: "Italian"}
    // ]
    @@ -302,8 +303,8 @@

    Deletes all items if no parameter was passed.

    -

    key: string: Deletes the entry whose key was passed as a string.

    -

    keys: string[]: Deletes the entries whose keys were passed in an array.

    +

    key: string: Deletes the item whose key was passed as a string.

    +

    keys: string[]: Deletes the items whose keys were passed in an array.

    import { BunSqliteKeyValue } from "bun-sqlite-key-value"

    const store = new BunSqliteKeyValue()

    // Delete all items
    store.delete()
    store.clear()

    // Delete one item
    store.delete("myKey")
    delete store.data.myKey

    // Delete multiple items
    store.delete(["key1", "key2"])
    @@ -311,10 +312,10 @@

    Deletes all expired items. -These are entries whose TTL (Time to live) has expired. -These entries are not deleted continuously, +These are items whose TTL (Time to live) has expired. +These items are not deleted continuously, but only when they are accessed directly or when the database is opened. -If you want to delete the expired entries in between, +If you want to delete the expired items in between, you can do this with deleteExpired().

    deleteOldExpiringItems(maxExpiringItemsInDb?: number)
     
    @@ -329,7 +330,7 @@

    Returns the number of all items, including those that have already expired. -The fact that possibly expired entries are also counted is for reasons of speed. +The fact that possibly expired items are also counted is for reasons of speed. Use getCountValid() if you want to get the number of items that have not yet expired. If you do not use ttlMs (time to live), getCount() is faster than getCountValid().

    import { BunSqliteKeyValue } from "bun-sqlite-key-value"

    const store = new BunSqliteKeyValue()

    store.set("my-key1", "my-value1")
    store.set("my-key2", "my-value2")

    store.getCount() // --> 2
    store.length // --> 2 @@ -340,10 +341,10 @@

    Returns the number of valid (non-expired) items. Can also delete the expired items.

    -

    If true is passed, the expired entries are deleted first -before the entries are counted.

    +

    If true is passed, the expired items are deleted first +before the items are counted.

    If the parameter is not specified or false is passed, -then only the entries that have no expiration date or +then only the items that have no expiration date or whose expiration date is in the future are counted.

    import { BunSqliteKeyValue } from "bun-sqlite-key-value"

    const store = new BunSqliteKeyValue()

    store.set("my-key1", "my-value1")
    store.set("my-key2", "my-value2", 100)

    store.getCountValid() // --> 2

    await Bun.sleep(500)
    store.getCountValid() // --> 1
    @@ -642,4 +643,4 @@ And if you speak German, here is my business homepage: GP-Softwaretechnik Maybe you will find something interesting for you there. 😃

    -
    +
    diff --git a/docs/interfaces/interfaces.Item.html b/docs/interfaces/interfaces.Item.html new file mode 100644 index 0000000..8fe9e01 --- /dev/null +++ b/docs/interfaces/interfaces.Item.html @@ -0,0 +1,2 @@ +Item | Bun SQlite Key Value

    Key value pair

    +

    Type Parameters

    • T
    diff --git a/docs/interfaces/interfaces.Options.html b/docs/interfaces/interfaces.Options.html new file mode 100644 index 0000000..0c4a47e --- /dev/null +++ b/docs/interfaces/interfaces.Options.html @@ -0,0 +1,16 @@ +Options | Bun SQlite Key Value

    Database options

    +
    interface Options {
        create?: boolean;
        maxExpiringItemsInDb?: MaxExpiringItems;
        readonly?: boolean;
        readwrite?: boolean;
        ttlMs?: TtlMs;
    }

    Properties

    create?: boolean

    Allow creating a new database (default: true). +If the database folder does not exist, it will be created.

    +
    maxExpiringItemsInDb?: MaxExpiringItems

    Default value that specifies the maximum number of +expiring items that may be in the database. +Is used by the deleteOldExpiringItems() method as default value.

    +
    readonly?: boolean

    Open the database as read-only (default: false).

    +
    readwrite?: boolean

    Open the database as read-write (default: true).

    +
    ttlMs?: TtlMs

    Default TTL milliseconds. +Standard time period in milliseconds before an entry written to the DB becomes invalid.

    +
    diff --git a/docs/interfaces/interfaces.Record.html b/docs/interfaces/interfaces.Record.html new file mode 100644 index 0000000..8791871 --- /dev/null +++ b/docs/interfaces/interfaces.Record.html @@ -0,0 +1,2 @@ +Record | Bun SQlite Key Value

    Table row (internally used)

    +
    diff --git a/docs/modules/index.html b/docs/modules/index.html new file mode 100644 index 0000000..65cfa3a --- /dev/null +++ b/docs/modules/index.html @@ -0,0 +1,7 @@ +index | Bun SQlite Key Value
    diff --git a/docs/modules/interfaces.html b/docs/modules/interfaces.html new file mode 100644 index 0000000..1878ff4 --- /dev/null +++ b/docs/modules/interfaces.html @@ -0,0 +1,9 @@ +interfaces | Bun SQlite Key Value

    Index

    Interfaces

    Type Aliases

    diff --git a/docs/types/interfaces.Field.html b/docs/types/interfaces.Field.html new file mode 100644 index 0000000..4a10342 --- /dev/null +++ b/docs/types/interfaces.Field.html @@ -0,0 +1,2 @@ +Field | Bun SQlite Key Value
    Field: string

    Field Name

    +
    diff --git a/docs/types/interfaces.Key.html b/docs/types/interfaces.Key.html new file mode 100644 index 0000000..72511f0 --- /dev/null +++ b/docs/types/interfaces.Key.html @@ -0,0 +1,2 @@ +Key | Bun SQlite Key Value
    Key: string

    Key

    +
    diff --git a/docs/types/interfaces.MaxExpiringItems.html b/docs/types/interfaces.MaxExpiringItems.html new file mode 100644 index 0000000..93ffcb7 --- /dev/null +++ b/docs/types/interfaces.MaxExpiringItems.html @@ -0,0 +1,5 @@ +MaxExpiringItems | Bun SQlite Key Value
    MaxExpiringItems: number | undefined

    Specifies the maximum number of expiring entries that may be in the database.

    +

    If there are more expiring items in the database than MaxExpiringItems, +the oldest items are deleted until there are only MaxExpiringItems items +with an expiration date in the database.

    +
    diff --git a/docs/types/interfaces.Tag.html b/docs/types/interfaces.Tag.html new file mode 100644 index 0000000..5662f45 --- /dev/null +++ b/docs/types/interfaces.Tag.html @@ -0,0 +1,2 @@ +Tag | Bun SQlite Key Value
    Tag: string

    Tag

    +
    diff --git a/docs/types/interfaces.TtlMs.html b/docs/types/interfaces.TtlMs.html new file mode 100644 index 0000000..701af55 --- /dev/null +++ b/docs/types/interfaces.TtlMs.html @@ -0,0 +1,6 @@ +TtlMs | Bun SQlite Key Value
    TtlMs: number | undefined

    Time period in milliseconds before an entry written to the DB becomes invalid.

    +

    "Time to live" in milliseconds. After this time, +the item becomes invalid and is deleted from the database +the next time it is accessed or when the application is started. +Set the value to 0 if you want to explicitly deactivate the process.

    +
    diff --git a/docs/variables/index.INDEX_OUT_OF_RANGE_ERROR_LABEL.html b/docs/variables/index.INDEX_OUT_OF_RANGE_ERROR_LABEL.html new file mode 100644 index 0000000..d922bf0 --- /dev/null +++ b/docs/variables/index.INDEX_OUT_OF_RANGE_ERROR_LABEL.html @@ -0,0 +1,2 @@ +INDEX_OUT_OF_RANGE_ERROR_LABEL | Bun SQlite Key Value

    Variable INDEX_OUT_OF_RANGE_ERROR_LABELConst

    INDEX_OUT_OF_RANGE_ERROR_LABEL: string = "[INDEX_OUT_OF_RANGE]"

    This error is raises if the index is out of range.

    +
    diff --git a/docs/variables/index.INVALID_COUNT_ERROR_LABEL.html b/docs/variables/index.INVALID_COUNT_ERROR_LABEL.html new file mode 100644 index 0000000..0cd5fd6 --- /dev/null +++ b/docs/variables/index.INVALID_COUNT_ERROR_LABEL.html @@ -0,0 +1,2 @@ +INVALID_COUNT_ERROR_LABEL | Bun SQlite Key Value

    Variable INVALID_COUNT_ERROR_LABELConst

    INVALID_COUNT_ERROR_LABEL: string = "[INVALID_COUNT_ERROR]"

    This error is raised if the count argument is invalid.

    +
    diff --git a/docs/variables/index.ITEM_NOT_EXISTS.html b/docs/variables/index.ITEM_NOT_EXISTS.html new file mode 100644 index 0000000..0f94428 --- /dev/null +++ b/docs/variables/index.ITEM_NOT_EXISTS.html @@ -0,0 +1,2 @@ +ITEM_NOT_EXISTS | Bun SQlite Key Value

    Variable ITEM_NOT_EXISTSConst

    ITEM_NOT_EXISTS: string = ITEM_NOT_EXISTS_ERROR_LABEL

    Use ITEM_NOT_EXISTS_ERROR_LABEL instead.

    +
    diff --git a/docs/variables/index.ITEM_NOT_EXISTS_ERROR_LABEL.html b/docs/variables/index.ITEM_NOT_EXISTS_ERROR_LABEL.html new file mode 100644 index 0000000..76871b1 --- /dev/null +++ b/docs/variables/index.ITEM_NOT_EXISTS_ERROR_LABEL.html @@ -0,0 +1,2 @@ +ITEM_NOT_EXISTS_ERROR_LABEL | Bun SQlite Key Value

    Variable ITEM_NOT_EXISTS_ERROR_LABELConst

    ITEM_NOT_EXISTS_ERROR_LABEL: string = "[ITEM_NOT_EXISTS]"

    This error is raised if the item does not exist.

    +
    diff --git a/docs/variables/index.NO_ARRAY_ERROR_LABEL.html b/docs/variables/index.NO_ARRAY_ERROR_LABEL.html new file mode 100644 index 0000000..f92884f --- /dev/null +++ b/docs/variables/index.NO_ARRAY_ERROR_LABEL.html @@ -0,0 +1,2 @@ +NO_ARRAY_ERROR_LABEL | Bun SQlite Key Value

    Variable NO_ARRAY_ERROR_LABELConst

    NO_ARRAY_ERROR_LABEL: string = "[NO_ARRAY_ERROR]"

    This error is raised if the value is not an array.

    +
    diff --git a/package.json b/package.json index 67f4919..cce94d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bun-sqlite-key-value", - "version": "1.11.3", + "version": "1.12.0", "author": { "name": "Gerold Penz", "email": "gerold@gp-softwaretechnik.at", diff --git a/src/index.ts b/src/index.ts index f94e647..ed0c316 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,9 +7,7 @@ import type { } from "./interfaces.ts" -/** - * Internally used database options - */ +// Internally used database options interface DbOptions extends Omit { strict: boolean } @@ -18,9 +16,26 @@ interface DbOptions extends Omit { const MIN_UTF8_CHAR: string = String.fromCodePoint(1) const MAX_UTF8_CHAR: string = String.fromCodePoint(1_114_111) +/** + * This error is raised if the `count` argument is invalid. + */ export const INVALID_COUNT_ERROR_LABEL: string = "[INVALID_COUNT_ERROR]" +/** + * This error is raised if the value is not an array. + */ export const NO_ARRAY_ERROR_LABEL: string = "[NO_ARRAY_ERROR]" -export const ITEM_NOT_EXISTS: string = "[ITEM_NOT_EXISTS]" +/** + * This error is raised if the item does not exist. + */ +export const ITEM_NOT_EXISTS_ERROR_LABEL: string = "[ITEM_NOT_EXISTS]" +/** + * @deprecated Use ITEM_NOT_EXISTS_ERROR_LABEL instead. + */ +export const ITEM_NOT_EXISTS: string = ITEM_NOT_EXISTS_ERROR_LABEL // Deprecated: +/** + * This error is raises if the `index` is out of range. + */ +export const INDEX_OUT_OF_RANGE_ERROR_LABEL: string = "[INDEX_OUT_OF_RANGE]" /** @@ -188,7 +203,7 @@ export class BunSqliteKeyValue { /** - * Delete all expired records + * Deletes all expired records. */ deleteExpired() { this.deleteExpiredStatement.run({now: Date.now()}) @@ -196,7 +211,7 @@ export class BunSqliteKeyValue { /** - * Delete one or multiple items + * Deletes one or multiple items. * * Inspired by: https://docs.keydb.dev/docs/commands/#del * @@ -225,7 +240,7 @@ export class BunSqliteKeyValue { /** - * Delete all items + * Deletes all items */ clear() { this.delete() @@ -712,9 +727,23 @@ export class BunSqliteKeyValue { } - // Do not use it with several very large amounts of data or blobs. - // This is because the entire data record with all fields is always read and written. - // Inspired by: https://docs.keydb.dev/docs/commands/#hset + // + + /** + * Hash (Map Object) - Write Value + * + * Do not use it with several very large amounts of data or blobs. + * This is because the entire data record with all fields is always read and written. + * + * Inspired by: https://docs.keydb.dev/docs/commands/#hset + * + * @category Hash (Map Object) + * @param {Key} key + * @param {Field} field + * @param {T} value + * @param {TtlMs} ttlMs + * @returns {boolean} + */ hSet(key: Key, field: Field, value: T, ttlMs?: TtlMs): boolean { // @ts-ignore (Transaction returns boolean, not void.) return this.db.transaction(() => { @@ -727,9 +756,21 @@ export class BunSqliteKeyValue { } - // Do not use it with several very large amounts of data or blobs. - // This is because the entire data record with all fields is always read and written. - // Inspired by: https://docs.keydb.dev/docs/commands/#hget + + + /** + * Hash (Map Object) - Read Value + * + * Do not use it with several very large amounts of data or blobs. + * This is because the entire data record with all fields is always read and written. + * + * Inspired by: https://docs.keydb.dev/docs/commands/#hget + * + * @category Hash (Map Object) + * @param {Key} key + * @param {Field} field + * @returns {T | undefined} + */ hGet(key: Key, field: Field): T | undefined { const map = this.get>(key) if (map === undefined) return @@ -737,9 +778,19 @@ export class BunSqliteKeyValue { } - // Do not use it with several very large amounts of data or blobs. - // This is because the entire data record with all fields is always read and written. - // Inspired by: https://docs.keydb.dev/docs/commands/#hmset + /** + * Hash (Map Object) - Write Multiple Values + * + * Do not use it with several very large amounts of data or blobs. + * This is because the entire data record with all fields is always read and written. + * + * Inspired by: https://docs.keydb.dev/docs/commands/#hmset + * + * @category Hash (Map Object) + * @param {Key} key + * @param {{[p: Field]: T}} fields + * @param {TtlMs} ttlMs + */ hmSet(key: Key, fields: {[field: Field]: T}, ttlMs?: TtlMs) { this.db.transaction(() => { const map = this.get>(key) ?? new Map() @@ -751,9 +802,19 @@ export class BunSqliteKeyValue { } - // Do not use it with several very large amounts of data or blobs. - // This is because the entire data record with all fields is always read and written. - // Inspired by: https://docs.keydb.dev/docs/commands/#hmget + /** + * Hash (Map Object) - Read Multiple Values + * + * Do not use it with several very large amounts of data or blobs. + * This is because the entire data record with all fields is always read and written. + * + * Inspired by: https://docs.keydb.dev/docs/commands/#hmget + * + * @category Hash (Map Object) + * @param {Key} key + * @param {string[]} fields + * @returns {{[p: Field]: T | undefined} | undefined} + */ hmGet(key: Key, fields?: string[]): {[field: Field]: T | undefined} | undefined { const map = this.get>(key) if (map === undefined) return @@ -769,10 +830,21 @@ export class BunSqliteKeyValue { } - // Returns if `field` is an existing field in the hash stored at `key`. - // Do not use it with several very large amounts of data or blobs. - // This is because the entire data record with all fields is always read. - // Inspired by: https://docs.keydb.dev/docs/commands/#hexists + /** + * Hash (Map Object) - Has Field + * + * Returns if `field` is an existing field in the hash stored at `key`. + * + * Do not use it with several very large amounts of data or blobs. + * This is because the entire data record with all fields is always read. + * + * Inspired by: https://docs.keydb.dev/docs/commands/#hexists + * + * @category Hash (Map Object) + * @param {Key} key + * @param {Field} field + * @returns {boolean | undefined} + */ hHasField(key: Key, field: Field): boolean | undefined { const map = this.get>(key) if (map === undefined) return @@ -784,7 +856,15 @@ export class BunSqliteKeyValue { hExists = this.hHasField - // Inspired by: https://docs.keydb.dev/docs/commands/#hlen + /** + * Hash (Map Object) - Count Fields + * + * Inspired by: https://docs.keydb.dev/docs/commands/#hlen + * + * @category Hash (Map Object) + * @param {Key} key + * @returns {number | undefined} + */ hGetCount(key: Key): number | undefined { const map = this.get>(key) if (map === undefined) return @@ -796,7 +876,15 @@ export class BunSqliteKeyValue { hLen = this.hGetCount - // Inspired by: https://docs.keydb.dev/docs/commands/#hkeys + /** + * Hash (Map Object) - Get All Field Names + * + * Inspired by: https://docs.keydb.dev/docs/commands/#hkeys + * + * @category Hash (Map Object) + * @param {Key} key + * @returns {string[] | undefined} + */ hGetFields(key: Key): string[] | undefined { const map = this.get>(key) if (map === undefined) return @@ -804,9 +892,7 @@ export class BunSqliteKeyValue { } - /** - * Alias for hGetFields() - */ + // Alias for hGetFields() hKeys = this.hGetFields @@ -821,6 +907,7 @@ export class BunSqliteKeyValue { * * Inspired by: https://docs.keydb.dev/docs/commands/#hvals * + * @category Hash (Map Object) * @param {Key} key * @returns {T[] | undefined} * If the data record (marked with `key`) does not exist, `undefined` is returned. @@ -845,17 +932,16 @@ export class BunSqliteKeyValue { } - /** - * Alias for hGetValues() - */ + // Alias for hGetValues() hVals = this.hGetValues /** - * Hash function: Delete a field of the map object. + * Hash function: Deletes a field of the map object. * * Inspired by: https://docs.keydb.dev/docs/commands/#hdel * + * @category Hash (Map Object) * @param {Key} key - The key of the item. * @param {Field} field - The name of the field. * @returns {boolean | undefined} @@ -878,6 +964,7 @@ export class BunSqliteKeyValue { /** * Inspired by: https://docs.keydb.dev/docs/commands/#hincrby * + * @category Hash (Map Object) * @param {Key} key * @param {Field} field * @param {number} incrBy @@ -906,6 +993,7 @@ export class BunSqliteKeyValue { /** * Inspired by: https://docs.keydb.dev/docs/commands/#hincrby * + * @category Hash (Map Object) * @param {Key} key * @param {Field} field * @param {number} decrBy @@ -922,6 +1010,7 @@ export class BunSqliteKeyValue { * * Inspired by: https://docs.keydb.dev/docs/commands/#lpush * + * @category List (Array Object) * @param {Key} key * @param {T} values * @returns {number} @@ -953,6 +1042,7 @@ export class BunSqliteKeyValue { * * Inspired by: https://docs.keydb.dev/docs/commands/#rpush * + * @category List (Array Object) * @param {Key} key * @param {T} values * @returns {number} @@ -983,6 +1073,7 @@ export class BunSqliteKeyValue { * * Inspired by: https://docs.keydb.dev/docs/commands/#lpop * + * @category List (Array Object) * @param {Key} key * @param {number} count * @returns { T | T[] | undefined} @@ -1023,6 +1114,7 @@ export class BunSqliteKeyValue { * * Inspired by: https://docs.keydb.dev/docs/commands/#rpop * + * @category List (Array Object) * @param {Key} key * @param {number} count * @returns {T[] | T | undefined} @@ -1067,6 +1159,7 @@ export class BunSqliteKeyValue { * * Inspired by: https://docs.keydb.dev/docs/commands/#lindex * + * @category List (Array Object) * @param {Key} key * @param {number} index * @returns {T | undefined} @@ -1094,6 +1187,7 @@ export class BunSqliteKeyValue { * * Inspired by: https://www.dragonflydb.io/docs/command-reference/lists/llen * + * @category List (Array Object) * @param {Key} key * @returns {number} * The length of the list at `key`. @@ -1108,20 +1202,46 @@ export class BunSqliteKeyValue { } - // ToDo: lSet() - // Achtung, wenn ein Index übergeben wird, der nicht im Array enthalten ist, soll ein Fehler ausgelöst werden. - // Achtung, es können auch negative Werte wie bei `.at()` als Index verwendet werden. - // - // function setAt(array: Array, index: number, value: T) { - // const len = array.length - // if (index < 0) { - // array[len + index] = value - // } else { - // array[index] = value - // } - // } - // - // Inspired by: https://docs.keydb.dev/docs/commands/#lset + /** + * Updates the list element at `index` to `value`. + * + * For more information on the index argument, see `lIndex()`. + * + * An error is returned if the key does not exist. + * An error is returned when the value stored at `key` is not an array. + * An error is returned for out of range indexes. + * + * Inspired by: https://www.dragonflydb.io/docs/command-reference/lists/lset + * + * @category List (Array Object) + * @param {Key} key + * @param {number} index + * @param {T} value + * @returns `true` if the `key` exists and the value has been set. + */ + lSet(key: Key, index: number, value: T): true { + // @ts-ignore (Transaction returns boolean or undefined, not void.) + return this.db.transaction(() => { + const array = this.get>(key) + if (array === undefined) { + throw new Error(ITEM_NOT_EXISTS_ERROR_LABEL + ` Key "${key.substring(-80)}" not found.`) + } + if (Array.isArray(array) === false) { + throw new Error(NO_ARRAY_ERROR_LABEL + ` Value at "${key.substring(-80)}" is not an array.`) + } + const len = array.length + if (index >= len || index < (len * -1)) { + throw new Error(INDEX_OUT_OF_RANGE_ERROR_LABEL + ` Array length: ${len}`) + } + if (index < 0) { + array[len + index] = value + } else { + array[index] = value + } + this.set>(key, array) + return true + }).immediate() + } // ToDo: lRange() @@ -1197,6 +1317,7 @@ export class BunSqliteKeyValue { * * Raises an error if the item key does not exist. * + * @category Tags (Labels) * @param {Key} key * @param {Tag} tag * @returns {boolean} @@ -1208,7 +1329,7 @@ export class BunSqliteKeyValue { return this.addTagStatement.run({item_key: key, tag}).changes === 1 } catch (error: any) { if (error.toString().includes("FOREIGN KEY constraint failed")) { - throw new Error(ITEM_NOT_EXISTS) + throw new Error(ITEM_NOT_EXISTS_ERROR_LABEL + ` Key "${key.substring(-80)}" not found.`) } else { throw error } @@ -1219,6 +1340,7 @@ export class BunSqliteKeyValue { /** * Deletes a tag of an item. * + * @category Tags (Labels) * @param {Key} key * @param {Tag} tag * @returns {boolean} @@ -1233,6 +1355,7 @@ export class BunSqliteKeyValue { /** * Deletes multiple tags or all tags of the item. * + * @category Tags (Labels) * @param {Key} key * @param {Tag[] | undefined} tags * Deletes all tags within the array. @@ -1252,6 +1375,7 @@ export class BunSqliteKeyValue { /** * Deletes tagged items. * + * @category Tags (Labels) * @param {Tag} tag */ deleteTaggedItems(tag: Tag) { @@ -1259,6 +1383,13 @@ export class BunSqliteKeyValue { } + /** + * Returns tagged keys. + * + * @category Tags (Labels) + * @param {Tag} tag + * @returns {Key[] | undefined} + */ getTaggedKeys(tag: Tag): Key[] | undefined { const records = this.getTaggedKeysStatement.all({tag}) if (!records?.length) return @@ -1266,6 +1397,13 @@ export class BunSqliteKeyValue { } + /** + * Returns tagged values. + * + * @category Tags (Labels) + * @param {Tag} tag + * @returns {(T | undefined)[] | undefined} + */ getTaggedValues(tag: Tag): (T | undefined)[] | undefined { return this.db.transaction(() => { const taggedKeys = this.getTaggedKeys(tag) @@ -1275,6 +1413,13 @@ export class BunSqliteKeyValue { } + /** + * Returns tagged items. + * + * @category Tags (Labels) + * @param {Tag} tag + * @returns {Item[] | undefined} + */ getTaggedItems(tag: Tag): Item[] | undefined { return this.db.transaction(() => { const taggedKeys = this.getTaggedKeys(tag) diff --git a/tests/memory.test.ts b/tests/memory.test.ts index c21aa8f..ebbafed 100644 --- a/tests/memory.test.ts +++ b/tests/memory.test.ts @@ -1,9 +1,8 @@ import { expect, test } from "bun:test" -import { BunSqliteKeyValue, INVALID_COUNT_ERROR_LABEL, ITEM_NOT_EXISTS, NO_ARRAY_ERROR_LABEL } from "../src" +import { BunSqliteKeyValue, INDEX_OUT_OF_RANGE_ERROR_LABEL, INVALID_COUNT_ERROR_LABEL, ITEM_NOT_EXISTS_ERROR_LABEL, NO_ARRAY_ERROR_LABEL } from "../src" import { Statement } from "bun:sqlite" import type { Item } from "../src/interfaces.ts" - const KEY_1: string = "test-key-1" const KEY_2: string = "test-key-2" const KEY_3: string = "test-key-3" @@ -893,7 +892,7 @@ test("Add tags", async () => { // Item does not exist. expect(() => { store.addTag(KEY_2, TAG_1) - }).toThrowError(ITEM_NOT_EXISTS) + }).toThrowError(ITEM_NOT_EXISTS_ERROR_LABEL) }) @@ -1016,3 +1015,24 @@ test("lLen()", async () => { }).toThrowError(NO_ARRAY_ERROR_LABEL) expect(store.lLen(KEY_3)).toEqual(0) }) + + +test("lSet()", async () => { + const store = new BunSqliteKeyValue() + + store.rPush(KEY_1, "one", "two", "three") + + expect(store.lSet(KEY_1, 0, "four")).toBeTrue() + expect(store.lSet(KEY_1, -2, "five")).toBeTrue() + expect(store.get>(KEY_1)).toEqual(["four", "five", "three"]) + expect(() => { + store.lSet(KEY_1, 3, "six") + }).toThrowError(INDEX_OUT_OF_RANGE_ERROR_LABEL) + expect(() => { + store.lSet(KEY_1, -4, "seven") + }).toThrowError(INDEX_OUT_OF_RANGE_ERROR_LABEL) + expect(() => { + store.lSet(KEY_2, 0, "eight") + }).toThrowError(ITEM_NOT_EXISTS_ERROR_LABEL) + +}) diff --git a/typedoc.json b/typedoc.json index 7b38486..e03e64b 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,21 +1,25 @@ { "$schema": "https://typedoc.org/schema.json", "entryPoints": [ - "src/index.ts" + "src/*.ts", + "src/**/*.ts" ], - "out": "docs/api", + "out": "docs", "name": "Bun SQlite Key Value", "navigationLinks": { "GitHub": "https://github.com/gerold-penz/bun-sqlite-key-value" }, - "exclude": [ - "./README.md" - ], "lightHighlightTheme": "github-light", "darkHighlightTheme": "github-dark", "sourceLinkExternal": true, "searchInComments": true, "searchInDocuments": true, - "excludeNotDocumented": true + "excludeNotDocumented": true, + "customFooterHtml": "By Gerold Penz - GP-Softwaretechnik.", + "hideParameterTypesInTitle": false + // "exclude": [ + // "./README.md" + // ], + // "projectDocuments": ["./README.md"], // "readme": "none" }