问题
Getting this error on the this.realm = line below. Not sure why as this code worked when it was formatted as a factory function
import Realm from 'realm';
export default function Db() {
this.realm = new Realm({
schema: [Wallet, WalletAddress, WalletTransaction, Log, APIWallet, APITransaction, APIAccount, Configuration],
path: config.db_path
});
logger(2, realm.path);
}
Db.prototype.doOneToMany = function(one, many) {..};
Db.prototype.query = function(model, filter) {..};
Db.prototype.insert = function(model, options) {..};
Db.prototype.del = function(model, obj) {..};
Db.prototype.update = function(obj, options) {..};
Db.prototype.write = function(func) {..};
Db.prototype.close = function() {..};
Error
回答1:
Try by removing "default" keyword it will work fine...
export function Db() {
this.realm = new Realm({
schema: [Wallet, WalletAddress, WalletTransaction, Log, APIWallet, APITransaction, APIAccount, Configuration],
path: config.db_path
});
logger(2, realm.path);}
try this...
来源:https://stackoverflow.com/questions/49578503/cannot-read-property-default-of-undefined