Skip to content

query and update into/using vector #1257

@solarobot

Description

@solarobot

HI,

I have exactly same problem as below
refer to stackoverflow:
https://stackoverflow.com/questions/42260993/c-soci-query-into-vector-of-custom-object

to select batch of size rows to vector of custom struct.

template<> struct type_conversion
{
typedef values base_type;

static void from_base(const values& v, indicator /* ind */, Event& event)
{
    event.m_id = v.get<std::string>("id");
    event.m_title = v.get<std::string>("Title");
    event.m_description = v.get<std::string>("Description");
    event.m_date = v.get<std::tm>("Date");
}

static void to_base(const Event& event, values& v, indicator& ind)
{
    v.set("id", event.m_id);
    v.set("Title", event.m_title);
    v.set("Description", event.m_description);
    v.set("Date", event.m_date);

    ind = i_ok;
}

};

std::vector<Event*> events;
sql << "SELECT * FROM Event", into(events)

The compilation error below:

Image

Just wonder if this is supported in the latest version or workaround is necessary for this?
BTW, batch update from vector as well.

Appreciate the clarity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions