ldc-com-app/ComApp/src/App/Models/Setting.js

24 lines
493 B
JavaScript
Raw Normal View History

2022-09-29 16:22:58 +02:00
class SettingModel {
constructor(realm) {
this.schema = 'Settings';
this.realm = realm;
}
add(data) {
this.realm.write(() => {
if (data.id === undefined) {
let id: any = this.realm.objects(this.schema).max('id');
data.id = id === undefined ? 1 : id + 1;
}
try {
this.realm.create(this.schema, data, 'never');
} catch (e) {
console.log('db setting add', e);
}
});
}
}
export default SettingModel;