无法从领域数据库架构获取值

时间:2019-05-24 09:49:42

标签: react-native realm

我正在创建一个使用react-native和realm作为数据库的访客管理应用程序。 为了添加访问者,我使用带有各种文本字段的PopUpDialog。 一个是Headercomponent,它具有标题和用于显示弹出窗口的“ +”。

export const TodoSchema = {
    name: TODO_SCHEMA,
    primaryKey: 'id',
    properties: {
        id: 'int',    // primary key
        name: { type: 'string', indexed: true },
        age: { type: 'string', indexed: true },
        reason: { type: 'string', indexed: true },
        address: { type: 'string', indexed: true },
        visitorid: { type: 'string', indexed: true },
        visitingperson: { type: 'string', indexed: true },
        number: { type: 'string', indexed: true },
        done: { type: 'bool', default: false }
    }
};
export const TodoListSchema = {
    name: TODOLIST_SCHEMA,
    primaryKey: 'id',
    properties: {
        id: 'int',    // primary key
        name: 'string',
        creationDate: 'date',
        exitDate: 'date',
        todos: { type: 'list', objectType: TODO_SCHEMA }
    }
};

现在在主要组件中,我试图获取creationDate的值,并且由于未定义的ANY SUGGESTIONS会很好而已

MainComponent.js的代码

Imports required for components

import React, { Component } from 'react';
import { View, FlatList, Text, TouchableOpacity, StyleSheet, Alert } from 'react-native';
import { updateTodoList, deleteTodoList, queryAllTodoLists } from '../databases/allSchemas';
import realm from '../databases/allSchemas';
import Swipeout from 'react-native-swipeout';

import HeaderComponent from './HeaderComponent';
import PopupDialogComponent from './PopupDialogComponent';

let FlatListItem = props => {
    const { itemIndex, id, name, creationDate, exitDate, popupDialogComponent, onPressItem } = props;

这里我正尝试从db creationdate中获取对象,名称,id被重新定义为未定义

0 个答案:

没有答案