作者:蓝色春天绿意长 | 来源:互联网 | 2022-12-02 17:57
我正在尝试使用我的本机应用程序在本地设置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))
});
我在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', {});
错误就在那里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 (MetroClient.js:63), :29:22)
at tryCallTwo (core.js:45)
at doResolve (core.js:200)
at new Promise (core.js:66)
at insertNewConfig (eval at (MetroClient.js:63), :28:12)
at Object.SelectInstanceScreen._this.continueLogin [as onPress] (eval at (MetroClient.js:63), :74:37)
似乎open()
函数必须作为函数调用(_constructor必须是'function'类型),但很明显它open()
被称为函数.提前致谢.
1> C-lio Garcia..:
我想也许是最后一个版本(2.18.0)上的一个错误,尝试降级到2.16.0它会起作用.