So I am trying to return values which may not exists on the document yet. I am getting the following error. If I want to avoid the error should I use If-Exists on each variable that I am returning, or should just return the entire document and do field level check at the client end?
{
"position": [
"map",
"expr",
"in",
"object",
"postAuthorName",
"from"
],
"code": "value not found",
"description": "Value not found at path [data,username]."
}
This is my query
Map(
Paginate(Documents(Collection('posts')), {size: 1}),
Lambda(
"postRefs",
Let({
postDoc: Get(Var("postRefs")),
authorDoc: Get(Select(["data", "postAuthorId"], Var("postDoc"))),
communityDoc:
Get(Select(["data", "communityId"], Var("postDoc"))),
}, {
postId: Select(["ref", "id"], Var("postDoc")),
postTitle: Select(["data", "postTitle"], Var("postDoc")),
postText: Select(["data", "postText"], Var("postDoc")),
itemPrice: Select(["data", "itemPrice"], Var("postDoc")),
itemLocation: Select(["data", "itemLocation"], Var("postDoc")),
imageUrl: Select(["data", "imageUrl"], Var("postDoc")),
postAuthorId: Select(["ref", "id"], Var("authorDoc")),
postAuthorName: Select(["data", "username"], Var("authorDoc")),
postAuthorAvatarUrl:
Select(["data", "avatarUrl"], Var("authorDoc")),
communityId: Select(["ref", "id"], Var("communityDoc")),
communityName: Select(["data", "communityName"], Var("communityDoc")),
})))