1 Star 11 Fork 1

Asciphx / ccORM

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.cpp 2.09 KB
一键复制 编辑 原始数据 按行查看 历史
asciphx 提交于 2022-03-29 14:25 . update v1.6
#include "src/ccORM.hh"
auto D =
//D_mysql();
//D_pgsql();
D_sqlite("any.db");
#include "module.hh"
//Is the perfect person really the most useless person? I don't know which stupid idiot made the remark.
void test() {
Tab::ptr t = Tab::create(1, true, "日期更变", now(), vector<Type>{ Type{ 1,"typescript" } });
t->Update();//update
t->set(5, false, "更变", now(), vector<Type>{ Type{ 1,"python" }, Type{ 2,"ruby" } }); cout << t << '\n';
*t = json::parse(R"({"id":4,"ok":false,"name":"完美杰作","date":"2021-09-08 01:04:30","types":
[{"id":1,"language":"c++"},{"id":2,"tabs":[{"id":1,"name":"wtf!","ok":1}]},{"id":3,"language":"rust"}]})").get<Tab>();
t->types[1].language = "go programing"; t->types[1].tabs[0].name = "Megatron"; cout << t << '\n';
//cout << "The number with ID " << t->Insert() << " has been inserted\n";//After insertion, a new ID will be returned
//t->Delete();//delete
//Type ty{1, "wwzzgg", 3.1415926}; cout << "The number with ID " << ty.Insert() << " has been inserted\n";
cout << Tab::Q().orderBy(Tab::$date).GetArr(Sort::DESC) << '\n';
vector<Type> vu; vector<Tab> vt = Tab::Q().innerJoin<Type>(Tab::$id==Type::$id).GetArr(&vu); cout << vt << '\n';//one-to-one -> GetArr
*t = Tab::Q().where(Tab::$id == 9).GetOne(); cout << t << '\n';//null
Tab::Q().leftJoin<Type>().GetJson();//leftjoin test
}
int main(int argc, char* argv[]) {
clock_t start = clock(); test(); if constexpr (FastestDev) { return 0; }
Timer t; bool run = true;//Marks the running state of the second thread
t.setTimeout([&run] {
int i = 0; for (; i < 99999; ++i) {
Tab::Q().where(Tab::$id == 2).GetOne();
} printf("<%d>", i);
run = false;//Represents the end of the secondary thread
}, 6);
int i = 0; for (; i < 99998; ++i) {
Tab::Q().where(Tab::$id == 1).GetOne();
}//Multithreading test, here is the first thread, that is, the main thread
printf("<%d>", i);
while (run) { this_thread::yield(); }//If run is true, the program is prevented from ending prematurely
printf("\nuse %.6f seconds", (float)(clock() - start) / CLOCKS_PER_SEC);//Calculate the total time spent
return 0;
}
C++
1
https://gitee.com/ASCIPHX/ccORM.git
git@gitee.com:ASCIPHX/ccORM.git
ASCIPHX
ccORM
ccORM
main

搜索帮助