-
Notifications
You must be signed in to change notification settings - Fork 297
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
mapToClass is not working for ES6 class modules #75
Comments
mapToClass() should work with ES6 classes. Please link to an example in jsitor.com or similar showing what you do and explain what you were expecting. |
I can't find an online code editor that allows JS module imports. I'm using WebPack and I'm importing one file into another: The Module in this case is "Friend.js" // 'models/Friend.js'
//----------------------------------------------
export default class Friend {
constructor(options) {
this.id = 0;
this.name = null;
this.shoeSize = null;
if(options) {
this.id = options.id || this.id;
this.name = options.name || this.name;
this.shoeSize = options.shoeSize || this.shoeSize;
}
}
} The main file is 'main.js' - (from your example) // main.js
//----------------------------------------------
import Dexie from 'dexie';
import Friend from './models/Friend'
var db = new Dexie("FriendsDB");
db.version(1).stores({
friends: "++id,name,shoeSize,address.city"
});
db.friends.mapToClass(Friend); // it's like this gets ignored - or maybe it can't call constructor()?
db.friends.where("name").startsWithIgnoreCase("d").each(function(friend) {
assert (friend instanceof Friend); // = false
friend.log();
}).catch(function (e) {
console.error(e);
}); |
ok thanks. I'll try repro it. In jsitor you can just include dexie in a script tag in the html part. For webpack style online editor, check codesandbox. For example cloning this Dexie-based project |
I have a class like this:
Then I set it up like:
When I call the mapToClass, I have the imported Class ready - but it does not work. I call the data with 'get' and just get the raw data. It seems to just ignore it all together. Am I just not understanding how this works?
The text was updated successfully, but these errors were encountered: