bud*_*hiv 8 mobile realm local-storage react-native realm-mobile-platform
我正在尝试使用我的本机应用程序在本地设置Realm DB,但似乎有一个错误,我无法找出原因.我在这里遵循了文档和指南.
我的守则.
import Realm from 'realm';
export const ConfigSchema = {
name: 'Config',
primaryKey: 'key',
properties: {
key: 'string',
value: 'string'
}
};
export const databaseOptions = {
path: 'myappreactnative.realm',
schema: [ConfigSchema],
schemaVersion: 0
};
export const insertNewConfig = (newConfig) => new Promise((resolve, reject) => {
Realm.open(databaseOptions).then(realm => {
// realm.create('Config', newConfig);
// resolve(newConfig);
console.log(realm);
}).catch((error) => reject(error))
});
Run Code Online (Sandbox Code Playgroud)
我在insertNewConfig这里打电话,
let config = {
key: 'instanceUrl',
value: 'myurl.domain.value'
};
insertNewConfig(config).then((result) => {
console.log(result);
}).catch((error) => {
console.log(error);
});
this.props.navigation.navigate('Login', {});
Run Code Online (Sandbox Code Playgroud)
错误就在那里Realm.open(databaseOptions).首先,我虽然错误与realm.create但后来实现了原始线.
显示的错误是这样的.
Error: _constructor must be of type 'function', got (undefined)
at sendRequest (rpc.js:263)
at Object.createRealm (rpc.js:62)
at new Realm (index.js:102)
at Function.open (extensions.js:110)
at eval (eval at <anonymous> (MetroClient.js:63), <anonymous>:29:22)
at tryCallTwo (core.js:45)
at doResolve (core.js:200)
at new Promise (core.js:66)
at insertNewConfig (eval at <anonymous> (MetroClient.js:63), <anonymous>:28:12)
at Object.SelectInstanceScreen._this.continueLogin [as onPress] (eval at <anonymous> (MetroClient.js:63), <anonymous>:74:37)
Run Code Online (Sandbox Code Playgroud)
似乎open()函数必须作为函数调用(_constructor必须是'function'类型),但很明显它open()被称为函数.提前致谢.
| 归档时间: |
|
| 查看次数: |
1056 次 |
| 最近记录: |