0

https://github.com/realm/realm-browser-osx

I ran a git clone on the above GitHub so it's in my projects directory.

I downloaded the the Realm Browser app from the App Store but now I'm trying to use it in my React Native project. On the GitHub page (above), it says that Realm Browser is a small utility for Mac OS X that lets you open .realm files to view and modify their contents.

What .realm files are there to open? The items I want to put in Realm aren't in .realm files, they're inside my .js file. How would I go about fixing this?

Here's my .js file:

import React, { Component } from 'react';
import {TextInput, KeyboardAvoidingView, Text, StyleSheet, TouchableOpacity} from 'react-native';
import Third from './Third';

class Second extends Component {
    onButtonPress() {
        this.props.navigator.push({
            id: 'Third' // .js file name
        });
    }

    render() {
        const Realm = require('realm');

        class Email {}
        Email.schema = {
            name: 'Email',
            primaryKey: 'name',
            properties: {
                name: 'string',
            },
        };

        const realm = new Realm({schema: [Email]});

// Query
        let email = realm.objects('Email');
        // email.length // => 0

// Write
        realm.write(() => {
            email = realm.create('Email', {
                name: 'something'
            });

            realm.create('Email', {name: "else"}, true);
        });

        return(
            <KeyboardAvoidingView style={styles.container}>

                <TextInput
                    style={styles.userInput}
                    placeholder={" email"}
                />

                <TextInput
                    style={styles.userInput}
                    placeholder={" password"}
                    secureTextEntry={true}
                />

                <TouchableOpacity style={styles.buttonContainer}>
                    <Text onPress={this.onButtonPress.bind(this)} style={styles.buttonText}>Submit</Text>
                </TouchableOpacity>

            </KeyboardAvoidingView>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        padding: 20 // makes button horizontally longer.
    },

    userInput: {
        marginBottom: 20,
        height: 40,
        borderWidth: 4

    },

    userInput: {
        marginBottom: 20,
        backgroundColor: '#9b42f4',
        height: 40,
        borderRadius: 10,
        borderWidth: 1
    },

    buttonContainer: {
        backgroundColor: '#41bbf4',
        paddingVertical: 10,
        marginBottom: 20,
        borderRadius: 10
    },

    buttonText: {
        textAlign: 'center',
        color: '#FFFFFF'
    }
});

export default Second;
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
  • 1
    Possible duplicate of [How to find my realm file?](https://stackoverflow.com/questions/28465706/how-to-find-my-realm-file) – Gregg Jul 31 '17 at 19:32
  • Realm Browser can be used to inspect `.realm` files stored on a device (iOS or Android). I guess what you are trying to look for is the `Realm Object Server`. – Dávid Pásztor Jul 31 '17 at 19:49
  • @DávidPásztor I need the `default.realm` file so I can drag & drop it into `Xcode` in my project directory but I can't find it. – georgecarlin24 Jul 31 '17 at 20:35
  • The file is automatically created for you when you first launch you iOS app, you don't need to add it to your project. – Dávid Pásztor Jul 31 '17 at 21:29
  • @DávidPásztor But I don't see it in my project. This video https://www.youtube.com/watch?v=nS6YCq2OdeA shows what I'm talking about. This is the part I'm missing. Skip to part 1:34. – georgecarlin24 Aug 01 '17 at 01:39

0 Answers0