{"action":"closed","issue":{"url":"https://api.github.com/repos/realm/realm-js/issues/1737","repository_url":"https://api.github.com/repos/realm/realm-js","labels_url":"https://api.github.com/repos/realm/realm-js/issues/1737/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-js/issues/1737/comments","events_url":"https://api.github.com/repos/realm/realm-js/issues/1737/events","html_url":"https://github.com/realm/realm-js/issues/1737","id":310125792,"number":1737,"title":"Realm crashes when instantiated within a class or prototype","user":{"login":"arshbot","id":16762060,"avatar_url":"https://avatars3.githubusercontent.com/u/16762060?v=4","gravatar_id":"","url":"https://api.github.com/users/arshbot","html_url":"https://github.com/arshbot","followers_url":"https://api.github.com/users/arshbot/followers","following_url":"https://api.github.com/users/arshbot/following{/other_user}","gists_url":"https://api.github.com/users/arshbot/gists{/gist_id}","starred_url":"https://api.github.com/users/arshbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arshbot/subscriptions","organizations_url":"https://api.github.com/users/arshbot/orgs","repos_url":"https://api.github.com/users/arshbot/repos","events_url":"https://api.github.com/users/arshbot/events{/privacy}","received_events_url":"https://api.github.com/users/arshbot/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-30T17:44:05Z","updated_at":"2018-04-01T00:15:29Z","closed_at":"2018-04-01T00:15:29Z","author_association":"NONE","body":"## Goals\r\n\r\nInstantiate realm\r\n\r\n## Expected Results\r\n\r\nInstantiate realm without issue\r\n\r\n## Actual Results\r\n\r\n![screen shot 2018-03-30 at 1 02 02 pm](https://user-images.githubusercontent.com/16762060/38146571-8e8f8126-341c-11e8-98c8-b04ae6ad99cf.png)\r\n\r\n\r\n## Steps to Reproduce\r\n\r\nuse the code sample provided\r\n\r\n## Code Sample\r\n\r\n```\r\nimport Realm from 'realm';\r\nimport config from './config';\r\nimport Wallet from './models/Wallet';\r\nimport WalletAddress from './models/WalletAddress';\r\nimport WalletTransaction from './models/WalletTransaction';\r\nimport Log from './models/Log';\r\nimport { logger } from '../../utils/Logger';\r\nimport APITransaction from './models/APITransaction';\r\nimport APIWallet from './models/APIWallet';\r\nimport APIAccount from './models/APIAccount';\r\nimport Configuration from './models/Configuration';\r\n\r\nexport default function Db() {\r\n    this.realm = new Realm({\r\n        schema: [Wallet, WalletAddress, WalletTransaction, Log, APIWallet, APITransaction, APIAccount, Configuration],\r\n        path: config.db_path\r\n    });\r\n    logger(2, realm.path);\r\n}\r\n\r\n//https://realm.io/docs/javascript/latest/#to-many-relationships\r\nDb.prototype.doOneToMany = function(one, many) {\r\n    many.forEach(m => {\r\n        this.write(() => {\r\n            one.push(m);\r\n        });\r\n    });\r\n};\r\n\r\nDb.prototype.query = function(model, filter) {\r\n    let results = this.realm.objects(model);\r\n    if (filter) {\r\n        return results.filtered(filter);\r\n    }\r\n    return results;\r\n};\r\n\r\n/*\r\n\tSide note: You can create sub classes recursively. Let's see how that works \r\n\t\thttps://realm.io/docs/javascript/latest/#creating-objects\r\n\t\r\n    */\r\nDb.prototype.insert = function(model, options) {\r\n    if (options == undefined && model instanceof Realm.Object) {\r\n        this.write(() => {\r\n            this.realm.create(model);\r\n        });\r\n    } else {\r\n        this.write(() => {\r\n            this.realm.create(model, options);\r\n        });\r\n    }\r\n};\r\n\r\nDb.prototype.del = function(model, obj) {\r\n    this.write(() => {\r\n        this.realm.delete(obj);\r\n    });\r\n};\r\n\r\nDb.prototype.update = function(obj, options) {\r\n    this.write(() => {\r\n        Object.keys(options).map((key, attribute) => {\r\n            obj[key] = attribute;\r\n        });\r\n    });\r\n};\r\n\r\nDb.prototype.write = function(func) {\r\n    try {\r\n        this.realm.write(func);\r\n    } catch (e) {\r\n        logger(0, e);\r\n        throw new Error('Db.js :: Write operation failed ::', e);\r\n    }\r\n};\r\n\r\nDb.prototype.close = function() {\r\n    this.realm.close();\r\n};\r\n\r\n```\r\n\r\n## Version of Realm and Tooling\r\n\r\n- Realm JS SDK Version: \"^2.2.15\"\r\n- Node or React Native: 8.9\r\n- Client OS & Version: macOS\r\n- Which debugger for React Native: Chrome debugging\r\n"}}
{"actor":{"display_login":"arshbot"}}