[GH-ISSUE #96] Index on {key} not updated on insertion/deletion #57

Closed
opened 2026-05-23 08:28:36 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @appy-one on GitHub (Apr 29, 2022).
Original GitHub issue: https://github.com/appy-one/acebase/issues/96

Originally assigned to: @appy-one on GitHub.

Discussion #92 led to the discovery of this issue: an index on the special key {key} correctly indexes all current data upon creation, but is not updated on records being inserted or deleted, because it doesn't recognize it as a special key name.

Example:

await db.ref('collection').push({ text: `this item's key will be indexed` });

// Create index, above record will be included
await db.indexes.create('collection', '{key}');

await db.ref('collection').push({ text: `this item's key is not added to the index` });

This does not happen with keys of actual properties in the data. An index on key text would be updated in above example.

Background info: Using {key} in an index is useful if you have nested collections and want to lookup one or more items in such nested collection. For example, if you want to lookup where the post with key l2ksg00p000009lk8gdlh60h resides if there is a nested posts collection for each user: users/l2kshwwg000109lk0y45d25j/posts/l2ksg00p000009lk8gdlh60h when indexed with db.indexes.create('users/*/posts', '{key}') and queried with .filter('{key}', '==', 'l2ksg00p000009lk8gdlh60h')

Originally created by @appy-one on GitHub (Apr 29, 2022). Original GitHub issue: https://github.com/appy-one/acebase/issues/96 Originally assigned to: @appy-one on GitHub. Discussion #92 led to the discovery of this issue: an index on the special key `{key}` correctly indexes all current data upon creation, but is not updated on records being inserted or deleted, because it doesn't recognize it as a special key name. Example: ```js await db.ref('collection').push({ text: `this item's key will be indexed` }); // Create index, above record will be included await db.indexes.create('collection', '{key}'); await db.ref('collection').push({ text: `this item's key is not added to the index` }); ``` This does not happen with keys of actual properties in the data. An index on key `text` would be updated in above example. Background info: Using `{key}` in an index is useful if you have nested collections and want to lookup one or more items in such nested collection. For example, if you want to lookup where the post with key `l2ksg00p000009lk8gdlh60h` resides if there is a nested _posts_ collection for each _user_: `users/l2kshwwg000109lk0y45d25j/posts/l2ksg00p000009lk8gdlh60h` when indexed with `db.indexes.create('users/*/posts', '{key}')` and queried with `.filter('{key}', '==', 'l2ksg00p000009lk8gdlh60h')`
gitea-mirror 2026-05-23 08:28:36 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@appy-one commented on GitHub (May 9, 2022):

This issue has been fixed in v1.18.0

<!-- gh-comment-id:1120742019 --> @appy-one commented on GitHub (May 9, 2022): This issue has been fixed in v1.18.0
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase#57
No description provided.