Skip to content

Instantly share code, notes, and snippets.

@diosmosis
Created February 19, 2012 11:05
Show Gist options
  • Save diosmosis/1863189 to your computer and use it in GitHub Desktop.
Save diosmosis/1863189 to your computer and use it in GitHub Desktop.
cryo examples
using namespace cryo;
// define some entities
struct author
{
autogenerate<int>::type id;
std::string name;
};
CRYO_DECLARE_ENTITY(author, id, (name));
struct book
{
autogenerate<int>::type id;
std::string title;
author auth;
};
CRYO_DECLARE_ENTITY(book, id, (title)(auth));
// query a database that already has data
template <typename Connection>
typename Connection::uint_type count_books_for_author(
Connection const& conn, std::string const& name)
{
return count<book>(
col(&book::auth)(&author::name) == name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment