Skip to main content

Get Yes and No Votes

If a predicate-object pair in a transaction triggers the smart function, vote, then it will look up the votes for the relevant subject-predicate-object triple.

This function will return the same map (minus meta-data) that is returned when you issue the specified query normally.

We can use the get-all built-in smart function to get all the yes and no votes.

For example, the function to get all the no votes is:

[  {    "_id": "_fn",    "name": "noVotes",    "code": "(get-all (nth (vote) 0) [\"vote/noVotes\" \"_id\"] )"  }]

Add a the yesVotes Function


Use the same pattern as above to write a transaction that creates a new function, yesVotes, which retrieves all of the yes votes.