あり可能な構造:
私はレルムのドキュメントを使用するためにあなたを提案します - >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 [レルムプロジェクトファイルとネイティブどのように反応するか整理する方法は?]:// /image/gif/paws/1009701/how-to-organize-react-native-with-realm-project-files) –