Last active
May 26, 2016 01:05
-
-
Save Chris-Petty/2cb08fac6f1b3bc0bfced1538743c554 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Realm from 'realm'; | |
const IdentitySchema = { | |
name: 'Identity', | |
properties: { | |
name: 'string', | |
birthday: 'date', | |
address: 'string', | |
} | |
}; | |
const PersonSchema = { | |
name: 'Person', | |
properties: { | |
identity: 'Identity', | |
hasCar: 'bool', | |
} | |
} | |
const realm = new Realm({schema: [IdentitySchema, PersonSchema]}); | |
realm.write(() => { | |
realm.deleteAll(); | |
const identityOne = realm.create('Identity', { | |
name: 'Bob', | |
birthday: new Date(), | |
address: '123 Somewhere Land', | |
}); | |
const identityTwo = realm.create('Identity', { | |
name: 'glob', | |
birthday: new Date(), | |
address: '9000 Somewhere Land', | |
}) | |
realm.create('Person', { | |
identity: identityOne, | |
hasCar: true, | |
}); | |
realm.create('Person', { | |
identity: identityTwo, | |
hasCar: false, | |
}); | |
}); | |
const people = realm.objects('Person'); | |
const filterTest = people.filtered('identity.name CONTAINS[c] "Bob"'); // Works fine | |
const sortedTest1 = people.sorted('hasCar'); // Works fine | |
const sortedTest2 = people.sorted('identity.name'); // RSOD, "Property 'identity.name' does not exist on object type 'person'" | |
console.log(sortedTest2); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment