Reputation: 35326
I have this code:
EntityIterable iterable = null;
if(authId== null) {
iterable = txn.find(entityType, "publicRead", true).skip(skip).take(limit);
} else {
iterable = txn.getAll(entityType)
.union(txn.find(entityType, "read(" + authId+ ")", true))
.union(txn.find(entityType, "publicRead", false))
.union(txn.find(entityType, "publicRead" ,true)).skip(skip).take(limit);
}
}
I'm trying to figure out a way to be able to get results based on this logic:
publicRead
is true then return all Entities that have the property
set to true (trivia)The problems is this:
authId
is present then retrieve all Entities with publicRead = false && read(userIdauthIdRoleId) = true
or publicRead = true && read(authId) = true
How can this be achieved with the Xodus API?
Upvotes: 0
Views: 46
Reputation: 2053
This can be achieved in the following way:
EntityIterable publicRead = txn.find(entityType, "publicRead", true);
EntityIterable result;
if (authId == null) {
result = publicRead;
} else {
result =
txn.getAll(entityType).minus(publicRead).intersect(txn.find(entityType, "read(userIdauthIdRoleId)", true))
.union(publicRead.intersect(txn.find(entityType, "read(" + authId + ")", true)));
}
result = result.skip(skip).take(limit);
Upvotes: 1