nedb
nedb copied to clipboard
Added compound index. Fixes #93
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.
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.
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.
It should be good to go now :+1:
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.
@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).
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
Still open since 2 years?
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[];
...