I'm just getting started with Realm IO for React Native, and I have started with the following example code:
const Realm = require('realm');
class ReactNative_GrammarApp extends Component {
render() {
let realm = new Realm({
schema: [{name: 'Dog', properties: {name: 'string'}}]
});
realm.write(() => {
realm.create('Dog', {name: 'Rex'});
realm.create('Dog', {name: 'Bert'});
realm.create('Dog', {name: 'Sam'});
realm.create('Dog', {name: 'John'});
realm.create('Dog', {name: 'Simon'});
realm.create('Dog', {name: 'Larry'});
realm.create('Dog', {name: 'Seymor'});
});
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Count of Dogs in Realm: {realm.objects('Dog').length}
</Text>
</View>
);
}
}
My issue is that every time I refresh the app in the simulator then the count grows by 7. I can see why this would be happening in the code, but how would I go about creating a database that does not double in size every time I refresh the app? My experience is with things like MySQL, so this is pretty strange for me.