sqlite_orm sync_schema源碼即翻譯

源碼

            /***  This is a cute function used to replace migration up/down functionality.*  It performs check storage schema with actual db schema and:*  * if there are excess tables exist in db they are ignored (not dropped)*  * every table from storage is compared with it's db analog and*      * if table doesn't exist it is being created*      * if table exists its colums are being compared with table_info from db and*          * if there are columns in db that do not exist in storage (excess) table will be dropped and* recreated*          * if there are columns in storage that do not exist in db they will be added using `ALTER TABLE* ... ADD COLUMN ...' command*          * if there is any column existing in both db and storage but differs by any of* properties/constraints (type, pk, notnull, dflt_value) table will be dropped and recreated Be aware that* `sync_schema` doesn't guarantee that data will not be dropped. It guarantees only that it will make db* schema the same as you specified in `make_storage` function call. A good point is that if you have no db* file at all it will be created and all tables also will be created with exact tables and columns you* specified in `make_storage`, `make_table` and `make_column` call. The best practice is to call this* function right after storage creation.*  @param preserve affects on function behaviour in case it is needed to remove a column. If it is `false`* so table will be dropped if there is column to remove, if `true` -  table is being copied into another* table, dropped and copied table is renamed with source table name. Warning: sync_schema doesn't check* foreign keys cause it is unable to do so in sqlite3. If you know how to get foreign key info please* submit an issue https://github.com/fnc12/sqlite_orm/issues*  @return std::map with std::string key equal table name and `sync_schema_result` as value.* `sync_schema_result` is a enum value that stores table state after syncing a schema. `sync_schema_result`* can be printed out on std::ostream with `operator<<`.*/std::map<std::string, sync_schema_result> sync_schema(bool preserve = false) {auto con = this->get_connection();std::map<std::string, sync_schema_result> result;auto db = con.get();this->impl.for_each([&result, db, preserve, this](auto &tableImpl) {auto res = this->sync_table(tableImpl, db, preserve);result.insert({tableImpl.table.name, res});});return result;}

翻譯

            /*** 這是個可愛的功能,用來替代上/下遷移功能。它用實際的db模式來檢查存儲模式,并且 * * 如果db中存在多余的表,它們會被忽略(不被丟棄)。* 如果數據庫中存在多余的表,它們將被忽略(而不是丟棄)。* *存儲的每一個表都與它的db模擬表進行比較,然后再進行比較。* * 如果表不存在,則正在創建。* * 如果表存在,它的列與來自db的table_info進行比較,然后再進行比較。* *如果db中的列在存儲中不存在(多余的)表將會被刪除,并被刪除。* 重現的* * 如果存儲中的列在db中不存在,將使用`ALTER TABLE'添加。* ... ADD COLUMN ...' 命令* *如果db和存儲中都有任何一列,但因任何一個不同而不同。* 屬性/約束(type, pk, notnull, dflt_value)表將被刪除并重新創建。* `sync_schema`并不能保證數據不會被丟棄。它只保證它將使db* 模式與你在`make_storage`函數調用中指定的模式相同。一個很好的觀點是,如果你沒有db_storage* 文件將被創建,所有的表也將被創建為與你的表和列完全一致的表和列。* 在 "make_storage"、"make_table "和 "make_column "調用中指定。最好的做法是調用這個* 在創建存儲后立即執行函數。* @param preserve在需要刪除一列時影響函數的行為。如果是`false`,則會影響函數的行為。* 因此,如果有列要刪除,表將被刪除,如果`true`----表被復制到另一個表中。* 表,刪除和復制的表用源表名重命名。警告: sync_schema不檢查* 外鍵的原因是在sqlite3中無法做到。如果你知道如何獲取外鍵信息,請告訴我* 提交一個問題https://github.com/fnc12/sqlite_orm/issues* @return std::map with std::string key equal table name and `sync_schema_result` as value.* `sync_schema_result`是一個枚舉值,用于存儲同步模式后表的狀態。`sync_schema_result`是同步模式后存儲表狀態的枚舉值。* 可以用`operator<<`在std::ostream上打印出來。*/

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/446858.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/446858.shtml
英文地址,請注明出處:http://en.pswp.cn/news/446858.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

安卓布局UI簡介

安卓UI 用戶界面UI&#xff08;使用者界面&#xff09; ——系統和用戶之間進行交互和信息交換的媒體 由布局和組件組成 軟件設計&#xff1a;編碼設計和UI設計 布局 ——可定義應用中的界面結構 所有元素都使用View和Viewgroup對象的層次結構進行構建 view微件——構建用戶…

Windows查找JDK的路徑

第一步&#xff1a;確定是否安裝JDK 在控制臺輸入&#xff1a; java -version輸出結果&#xff1a; 此時說明你電腦安裝了JDK。 第二步&#xff1a;查找路徑 然后在控制臺輸入&#xff1a; java -verbose輸出結果&#xff1a; 從最后的jre目錄可以找到相應的jdk目錄。 …

boost官方文檔同步機制Synchronization mechanisms overview

參考鏈接 官方文檔 Synchronization mechanisms overview Named And Anonymous Synchronization MechanismsTypes Of Synchronization Mechanisms如前所述&#xff0c;如果不能有效地同步對內存的訪問&#xff0c;那么通過內存映射文件或共享內存對象在進程之間共享內存的能力…

安卓布局中xml文件屬性和ID簡介

編寫xml屬性 加載xml資源 當編譯應用時&#xff0c;系統會將每個xml文件編譯為view資源 屬性 xml屬性&#xff1a;特有屬性&#xff0c;共有屬性&#xff0c;其他屬性&#xff08;布局參數&#xff09; ID ——在結構樹中對view對象唯一標識 編譯應用后&#xff0c;系統以…

Java監控工具VisualVM

目錄一、簡介二、內存分析1、Heap堆三、CPU分析四、線程分析一、簡介 VisualVM 是一款免費的&#xff0c;集成了多個JDK命令行工具的可視化工具&#xff0c;它能為您提供強大的分析能力&#xff0c;對Java應用程序做 性能分析和調優 。這些功能包括 生成和分析海量數據、跟蹤內…

對官方Mutexes的翻譯

參考鏈接 參考鏈接 Mutexes Whats A Mutex?Mutex OperationsBoost.Interprocess Mutex Types And HeadersScoped lockAnonymous mutex exampleNamed mutex example Whats A Mutex? 互斥是相互排斥的意思&#xff0c;它是進程之間最基本的同步形式。互斥保證只有一個線程可…

計算機應用基礎

計算概論知識點 1.計算機之父&#xff1a;馮.諾伊曼 計算機基本組成&#xff1a;運算器&#xff0c;控制器&#xff0c;存儲器&#xff0c;輸入設備&#xff0c;輸出設備 2.幾種計算機&#xff1a;臺式計算機,筆記本式計算機,PC服務器,平板式計算機… 3.電腦的硬件&#xff1a;…

Android最全UI庫合集

目錄抽屜菜單ListViewWebViewSwitchButton按鈕點贊按鈕進度條TabLayout圖標下拉刷新ViewPager圖表(Chart)菜單(Menu)浮動菜單對話框空白頁滑動刪除手勢操作RecyclerViewCardColorDrawableSpinner布局模糊效果TabBarAppBar選擇器(Picker)跑馬燈日歷時間主題樣式ImageView通知聊天…

對于boost鎖機制結論性的介紹

Conditions Whats A Condition Variable?Boost.Interprocess Condition Types And HeadersAnonymous condition example Whats A Condition Variable? 在前面的例子中&#xff0c;一個mutex被用來鎖定&#xff0c;但我們不能用它來有效地等待&#xff0c;直到滿足繼續的條件…

C++數據類型

C 數據類型 |–基本數據類型: 整型 short短整型 2 int基本整型4 long長整型 8 浮點型 float單精度型 4 double雙精度型 8 long double長雙精度型 16 字符型 char 1 邏輯型 bool 1 空類型 void |–構造類型 數組類型 構造體類型 struct 共用體類型 union 枚舉類型 enum 類類型…

Android Gradle 多渠道打包、動態配置AppName

目錄一、簡介二、Gradle多渠道打包1、普通做法2、Gradle多渠道打包一、簡介 因為國內Android應用分發市場的現狀&#xff0c;我們在發布APP時&#xff0c;一般需要生成多個渠道包&#xff0c;上傳到不同的應用市場。這些渠道包需要包含不同的渠道信息&#xff0c;在APP和后臺交…

boost鎖機制中Semaphores的介紹

結構 Whats A Semaphore?Boost.Interprocess Semaphore Types And HeadersAnonymous semaphore example Whats A Semaphore? 旗語是一種基于內部計數的進程間同步機制&#xff0c;它提供了兩種基本操作。等待&#xff1a;測試旗語數的值&#xff0c;如果小于或等于0&#x…

Android Gradle 批量修改生成的apk文件名

目錄一、簡介二、代碼實現1、 Gradle 3.0以下版本2、Gradle 3.0以上版本一、簡介 平時開發都知道&#xff0c;我們要上線的時候需要在Android studio打包apk文件&#xff0c;可是默認的打包名是app-release.apk或者app-debug.apk這樣的名字&#xff0c;太沒有辨識度了。 下面…

C++boost Class named_condition翻譯

Class named_condition boost::interprocess::named_condition 簡介 // In header: <boost/interprocess/sync/named_condition.hpp>class named_condition { public:// construct/copy/destructnamed_condition(create_only_t, const char *, const permissions &…

Android Studio 代理設置以及代理完全清除

目錄一、代理設置二、代理完全清除一、代理設置 首先我們來看下怎樣設置代理&#xff0c;Mac下打開【Preferences…】&#xff0c;然后搜索"HTTP"&#xff0c;選擇【HTTP Proxy】&#xff0c;按圖中設置配置好后&#xff0c;點擊【Apply】&#xff0c;然后在點擊【O…

安卓布局位置,dp與px的區別

手機6寸—指對角線 布局位置 橫軸—x軸 縱軸—y軸 一個像素點 dp與Px dp:設備無關像素,與像素密度相關,像素距離 dpi:像素密度,每英寸包含的像素數 px:屏幕上一個物理像素點 ldpi低密度 1dp0.75px mdpi中密度 1dp1px hdpi高密度 1dp1.5px xhdpi超高密度 1dp2px xxhdpi超…

Android Studio 快捷鍵大全(Mac系統)

目錄一、Mac上的按鍵符號二、快捷鍵查找/查看相關控制操作相關代碼重構相關一、Mac上的按鍵符號 符號說明?option / alt?shift?control?command?esc 二、快捷鍵 查找/查看相關 快捷鍵說明雙擊 shift搜索任意內容command F / command R當前文件查找/替換&#xff0c;使…

ubuntu下clion軟件連接boost庫文件

整體配置 cmake_minimum_required(VERSION 3.17) project(mutex_learn)set(CMAKE_CXX_STANDARD 14) #boost庫所在的根目錄set(BOOST_ROOT "/usr/local/include/boost") #添加頭文件搜索路徑 include_directories(/usr/local/include) #添加庫文件搜索路徑 link_dir…

Android程序結構

Project方式 .gradle文件夾:編譯相關生成 .idea文件夾:idea生成 app文件夾----應用程序的源代碼和資源 build----編譯后的文件存放的位置,最終apk文件存放的位置 libs:存放.jar和.so文件 src:AndroidTest與test存放測試相關的內容 main中Java文件夾存放Java源碼,res文件…