-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not work for multiple indexes #21
Comments
Thanks for the request. Indeed support for many-to-many would be a nice feature. Part of the problem is how it parses indexes, but I believe that wouldn't solve it all. Anyone who have the time to fix this, please send a PR. |
I'm interested in this, could you provide a bit of info or references to how current multi index columns are handled? |
multiEntry indexes generally in indexedDB works on array properties rather than ordinary properties in such way that you can put an arbitrary number of keys into the array and a query that matches any of those keys will match. A simple example is a 'tags' based model, where you can tag the same row with multiple tags. var db = new Dexie ('mydb');
db.version(1).stores ({
books: 'id, author, name, *categories'
});
db.books.put({
id: 1,
name: 'Under the Dome',
author: 'Stephen King',
categories: ['sci-fi', 'thriller']
});
function queryBookByCategory(category) {
return db.books
.where('categories').equals(category)
.toArray ();
} If dexie-relationships would support putting foreign keys into multiEntry indexed arrays, we would have support for many-to-many relations without the need of a junction table. |
Hello! Thank you very much for this helpful and useful addon and for the Dexie!
It would be even better, if it would working with multiple indexes.
For example "*groupsIds -> group.id"
May be I have some problem with architecture of my app's DB, but I need that for example one item could be a member of 2 or more groups. (user is admin and buyer at same time, or MacBook is notebook and PC and topseller at the same time).
getForeignKeys() method doesn't cut off prefixes of fields before searching by index. But may be the problem is some deeper in core...
Thanks
The text was updated successfully, but these errors were encountered: