이 가능한 구조 :
나는 영역의 문서 사용을 제안합니다 ->https://realm.io/
이 가능한 구조 : realm.js
import * as RealmDB from 'realm';
class Passenger extends RealmDB.Object {}
Passenger.schema = {
name: 'Passenger',
primaryKey: 'id',
properties: {
'id' : 'string',
'firstname' : { type: 'string', optional: true },
'lastname' : { type: 'string', optional: true },
'birthdate' : { type: 'int', optional: true },
'email' : { type: 'string', optional: true },
'phone' : { type: 'string', optional: true },
'child' : { type: 'linkingObjects', objectType: 'Child', property: 'passengers' }
}
};
class Child extends RealmDB.Object {}
Child.schema = {
name: 'Child',
primaryKey: 'id',
properties: {
'id' : 'string',
'name' : 'string',
'parents_1' : { type: 'linkingObjects', objectType: 'Passenger', property: 'child' }
}
};
const realmInstance = new RealmDB({
schema: [Passenger, Child],
});
export default realmInstance;
use.js
을
import realm from "./realm";
export default class use {
static writeToRealm(){
realm.write(() => {
let passenger = realm.create('Passenger', {
'id' : "..."
'firstname' : "...",
'lastname' : "...",
"..."
})
}
static readPassengers(){
const passengers = realm.objects('Passengers');
return passengers // Be careful Realm use List instead of Array quite the same but not!
}
}
글을 쓸 때마다 데이터베이스는 realm.write를 사용해야합니다 (() => {})
이 도움이 :) 희망
[영역 프로젝트 파일과 기본 반작용 구성하는 방법?] (HTTPS의
가능한 중복 : // howovertoflow.com/questions/40195371/how-to-organize-react-native-with-realm-project-files) –