Skip to content

make_storage

Yevgeniy Zakharov edited this page Apr 17, 2019 · 5 revisions
template<class ...Ts>
internal::storage_t<Ts...> make_storage(const std::string &filename, Ts ...tables);

Creates storage object for further interacting with your sqlite3 database.

Parameters

(1) filename Database file name.

(2) tables Tables pack you need to be managed by library created with make_column.

Return value

internal::storage_t<Ts...> instance.

Example

struct Employee {
    int id;
    std::string name;
    int age;
    std::shared_ptr<std::string> address;   //  optional
    std::shared_ptr<double> salary; //  optional
};

using namespace sqlite_orm;
auto storage = make_storage("make_storage_example.sqlite",
                            make_table("COMPANY",
                                       make_column("ID", &Employee::id, primary_key()),
                                       make_column("NAME", &Employee::name),
                                       make_column("AGE", &Employee::age),
                                       make_column("ADDRESS", &Employee::address),
                                       make_column("SALARY", &Employee::salary)));