nedb icon indicating copy to clipboard operation
nedb copied to clipboard

Added compound index. Fixes #93

Open bengl opened this issue 10 years ago • 8 comments

As discussed in https://github.com/louischatriot/nedb/issues/93, this adds compound indexes.

I went with detecting whether fieldName is an array, rather than also having a fieldNames property in ensureIndex. Either way (or another way) is fine by me though, so let me know if you'd like me to change it.

bengl avatar Sep 23 '14 00:09 bengl

Hello,

Thanks for this, it looks really interesting. I need to find the time to review it but this is a priority compared to the other PRs.

louischatriot avatar Sep 26 '14 12:09 louischatriot

Upon further investigation, it looks like this doesn't quite work yet, as I hadn't touched Datastore.prototype.getCandidates, so the compound indexes aren't yet being used. I've now got that working locally. I'm just cleaning it up readying it for a commit. I'll close this and reopen it once I've got the commit pushed.

bengl avatar Nov 06 '14 00:11 bengl

It should be good to go now :+1:

bengl avatar Nov 06 '14 01:11 bengl

Hi @louischatriot, at DeNA, we've been using this feature for several months, and it has worked out well. It has been very useful to us for creating indexes in neDB that refer to multiple fields. Would you please merge this PR? Thank you.

johnmarkos avatar Apr 07 '15 23:04 johnmarkos

@bengl: I applaud you for implementing this cool feature. My one personal gripe is that I wish it was in sync with the MongoDB API for ensureIndex (NeDB is not in sync with that API in general, unfortunately).

JamesMGreene avatar Jan 09 '16 05:01 JamesMGreene

I have merged changes on both sides and fixes incompatibilities (all npm tests passed) If anyone interested, could grab from git://git.s2n.io/theshell/forks/nedb.git (branch theshell-merge) I'll merge PR to @bengl or here if I get chance to deal with it. For now, I guess below should do.

git remote add theshell-fork git://git.s2n.io/theshell/forks/nedb.git
git fetch theshell-fork theshell-merge
git merge theshell-fork/theshell-merge

Thanks for the work @bengl and @louischatriot

furkanmustafa avatar Mar 06 '16 19:03 furkanmustafa

Still open since 2 years?

psi-4ward avatar Dec 12 '16 13:12 psi-4ward

In case this is ever merged: Could someone also update the TypeScript type for the fieldName in @types/nedb's index.d.ts?

    interface EnsureIndexOptions {
        fieldName: string | string[];
        ...

MarcelWaldvogel avatar Jul 28 '20 15:07 MarcelWaldvogel