这里我举个例子
class TestRealm {
constructor(realmDB) {
this.realmDB = realmDB;
this.allRealm = this.realmDB.objects('Person');
}
query1(primary_key) {
try {
const response = this.allRealm.filtered(`_id == "${primary_key}"`);
if (response.length === 0) {
console.log('unable to find');
return;
}
return response.toJSON()[0];
}
catch (e) {
console.log(e);
}
}
query2(primary_key) {
try {
const response = this.realmDB.objectForPrimaryKey('Person', `"${primary_key}"`);
if (!response) {
console.log('unable to find');
return;
}
return response.toJSON();
}
catch (e) {
console.log(e);
}
}
}
假设在打开领域后,我将领域对象传递给 TestRealm 构造函数。在这种情况下,哪个查询对大数据有效?