日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

多索引表 (5)创建多索引表

發布時間:2025/3/21 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 多索引表 (5)创建多索引表 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 創建表

  • class/struct 定義一個持久化對象。
  • 該對象需要有一個const的成員作為主鍵,類型為uint64_t
  • 二級主鍵可選,提供不同的鍵類型
  • 為每個二級索引定義一個鍵導出器,鍵導出器是一個函數,可以用來從Multi_index表中獲取鍵

multi_index_example.hpp

#include <eosio/eosio.hpp> using namespace eosio;// multi index example contract class class [[eosio::contract]] multi_index_example : public contract {public:using contract::contract;// contract class constructormulti_index_example( name receiver, name code, datastream<const char*> ds ) :// contract base class contructorcontract(receiver, code, ds),// instantiate multi index instance as data member (find it defined below)testtab(receiver, receiver.value){ }// the row structure of the multi index table, that is, each row of the table// will contain an instance of this type of structurestruct [[eosio::table]] test_table {// this field stores a name for each row of the multi index tablename test_primary;// additional data stored in table rowuint64_t datum;// mandatory definition for primary key getteruint64_t primary_key( ) const { return test_primary.value; }};// the multi index type definition, for ease of use define a type alias `test_tables`, // based on the multi_index template type, parametarized with a random name and // the test_table data structuretypedef eosio::multi_index<"testtaba"_n, test_table> test_tables;// the multi index table instance declared as a data member of type test_tablestest_tables testtab;[[eosio::action]] void set( name user );[[eosio::action]] void print( name user );using set_action = action_wrapper<"set"_n, &multi_index_example::set>;using print_action = action_wrapper<"print"_n, &multi_index_example::print>; };

總結

以上是生活随笔為你收集整理的多索引表 (5)创建多索引表的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。