voteinfotable, as well as instructions on how to add an index to a table using the example of an
const_mem_funis used in the table description, or a field from the
eosio::memberstructure is used.
N(vote)— a primary index;
vote_table— a table name;
voteinfo— a structure name;
vote_id_index— a primary key index;
vote_messageid_index— an index identifying the message. For each vote, a message is formed during the voting, which is assigned a number. By this number, a message is searched in the table;
vote_group_index— secondary index, composite.
by_message, and by several fields.
const_mem_fun— description in a simple form;
eosio::member— description in a complex form.
composite_key, the name of the structure, and the list of fields from which the index is formed are indicated (for example, from the
infofields is the same as in EOS. The difference from EOS is that instead of the index fields
indexed_typeused in EOS, CyberWay uses the description of the indexes.
indexed_bytemplate. The match is as follows:
N(id)— a coincidence by the ordinal number of the parameter. For example, N1 is the choice of the primary index;
N(messageid)— a match by a sequence number of a message. Each vote is assigned a message number during voting;
N(byvoter)— a coincidence by ordinal number of the voter.
unique = truemeans uniqueness.
voter). The values of these fields must follow in the order in which they are contained in
const_mem_ func. The second
orderattribute defines how to build an index within the database. This parameter determines the order of occurrence of elements if these elements are extracted from the table one by one, that is, determines a rule by which the next element in the table is located.
messageidconsists of one field, the value
mssg_itr->idwhich will be passed to lower_bound, will also consist of one field.
lower_boundis used to search for the lower boundary by the specified ID. From the found lower limit, the index goes through all the votes, while the vote is considered to be cast for the same post.
byvoter— consists of two fields passed by
make_tuple. Used to search for votes related to the message
voter, the user who voted.
addressbook table. The following ones are the instructions for adding an index to this table.
bobuser entries in it.
index_by— the structure that is used to create an instance of the index.
«byage»— a function call operator that retrieves the value of const as an index key.
agefield in the
upsertfunction as follows:
bobby age index. In command lines, use the
--index 2parameter to specify a query on the secondary index (index No. 2).