[GH-ISSUE #86] Wildcards at index root #54

Closed
opened 2026-05-23 08:28:29 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @ThePhantomLemon on GitHub (Mar 18, 2022).
Original GitHub issue: https://github.com/appy-one/acebase/issues/86

Originally assigned to: @appy-one on GitHub.

db.indexes.create("*/media", "timestamp") 
.then(() => {
    return db.query("*/media") /
      .take(100)
      .sort("timestamp", false)
      .get();
})
.then((postSnapshots) => {
      console.log(postSnapshots)
});

The above code returns an error from line 1095 in data-index.js. specifically this line:

const wildcardValues = childPath.match(wildcardRE).slice(1);

match() is returning null so of course it errors when trying to call slice().
Presumably I should have my data just be 1 level deeper.

Originally created by @ThePhantomLemon on GitHub (Mar 18, 2022). Original GitHub issue: https://github.com/appy-one/acebase/issues/86 Originally assigned to: @appy-one on GitHub. ```js db.indexes.create("*/media", "timestamp") .then(() => { return db.query("*/media") / .take(100) .sort("timestamp", false) .get(); }) .then((postSnapshots) => { console.log(postSnapshots) }); ``` The above code returns an error from line 1095 in data-index.js. specifically this line: ```js const wildcardValues = childPath.match(wildcardRE).slice(1); ``` `match()` is returning null so of course it errors when trying to call `slice()`. Presumably I should have my data just be 1 level deeper.
Author
Owner

@appy-one commented on GitHub (Mar 19, 2022):

I tried to reproduce this but couldn't so I checked the code, The regular expression used expects the keys for wildcards to only contain characters A-Z, a-z, 0-9 and/or _. Do your keys maybe contain other characters than these?

<!-- gh-comment-id:1073065896 --> @appy-one commented on GitHub (Mar 19, 2022): I tried to reproduce this but couldn't so I checked the code, The regular expression used expects the keys for wildcards to only contain characters A-Z, a-z, 0-9 and/or _. Do your keys maybe contain other characters than these?
Author
Owner

@ThePhantomLemon commented on GitHub (Mar 20, 2022):

Hey, so I ran all the keys through a regex and stuff to check and everything was fine. But then I decided to try the above code again and it works now. It's a possibility that when I initially ran this the database wasn't ready yet, since I refactored quite a bit since then. IDK if that would result in this kind of issue though. In any case I can't reproduce it.

<!-- gh-comment-id:1073138416 --> @ThePhantomLemon commented on GitHub (Mar 20, 2022): Hey, so I ran all the keys through a regex and stuff to check and everything was fine. But then I decided to try the above code again and it works now. It's a possibility that when I initially ran this the database wasn't ready yet, since I refactored quite a bit since then. IDK if that would result in this kind of issue though. In any case I can't reproduce it.
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#54
No description provided.