Skip to content

storage_t::current_timestamp

Yevgeniy Zakharov edited this page Mar 30, 2017 · 2 revisions
std::string current_timestamp();

Performs SELECT CURRENT_TIMESTAMP and returns the result as std::string.

Return value

Current timestamp generated by sqlite3 engine. Example: 2017-03-05 15:37:14

Example

struct Human {
    int company;
    std::string name;
    std::shared_ptr<std::string> job;
};
using namespace sqlite_orm;
auto storage = make_storage("jobs.sqlite",
                            make_table("jobs",
                                       make_column("company",
                                                   &Human::company),
                                       make_column("name",
                                                   &Human::name),
                                       make_column("job",
                                                   &Human::job)));
storage.sync_schema();

auto currentTimestamp = storage.current_timestamp();
cout << "currentTimestamp = " << currentTimestamp << endl;

Output:

currentTimestamp = 2017-03-05 15:37:14

Note

It doesn't matter what classes are mapped to storage - this function call doesn't depend on any of mapped classes.