Это мой файл RealmService:
import Realm from 'realm';
const AuthSchema = {
name: 'Auth',
primaryKey: 'id',
properties: {
id: {
type: 'int',
indexed: true
},
time: 'date',
username: 'string',
action: 'string'
}
}
const WiretransferSchema = {
name: 'Wiretransfer',
primaryKey: 'id',
properties: {
id: {
type: 'int',
indexed: true
},
time: 'date',
source: 'string',
target: 'string',
amount: 'float',
comments: {
type: 'string',
optional: true
}
}
}
let RealmService = {
findAllAuth: function() {
return repository.objects('Auth');
},
SaveAuth: function(username, action) {
Realm.open({
path: 'testtt.realm',
schema: [AuthSchema, WiretransferSchema]
}).then(realm => {
// Get max ID
var maxId = realm.objects('Auth').max('id');
realm.write(() => {
realm.create('Auth', {
id: maxId + 1,
time: Date.now(),
username: username,
action: action
}, true);
});
realm.close();
}).catch(err => {
console.log(err);
});
}
}
module.exports = RealmService;
Приложение вылетает без ошибок при вызове этого кода:
realm.write(() => {
realm.create('Auth', {
id: maxId + 1,
time: Date.now(),
username: username,
action: action
}, true);
});
Просто метод записи не приводит к сбою приложения. Это метод создания.
Если я отключаю средства отладки в React Native, приложение не вылетает, но в файл области ничего не добавляется.
Я пробовал RN 0,57,1 и 0,57,8. Переустановил царство и все равно не повезло. В чем может быть проблема?