Whenever I run my program I come up with the error unknown
on line 16
let zeros = realm.objects('zero', 'age >= 17');
I have no Idea what is wrong with it, I have played around with syntax and all sorts of variable names, yet am unable to yield a positive result. Here is the rest of the code for reference, it is stock code from the Realm website.
const Realm = require('realm');
class zero {}
zero.schema = {
name: 'zero',
primaryKey: 'name',
properties: {
name: 'string',
age: {type: 'int', default: 0},
},
};
const realm = new Realm({schema: [zero]});
// Query
let zeros = realm.objects('zero', 'age >= 17');
zeros.length // => 0
// Write
realm.write(() => {
savedzero = realm.create('zero', {
name: 'Hal Incandenza',
age: 17,
});
});
// Queries are updated in real-time
zeros.length // => 1
Thanks in advance!!!
The realm.objects()
method only accepts one argument. Instead, you want to write: realm.objects('zero').filtered('age >= 17')
It should be giving you a more useful error message than unknown
however. Are you on the latest version, 0.13.2?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.