Created
February 19, 2012 11:05
-
-
Save diosmosis/1863189 to your computer and use it in GitHub Desktop.
cryo examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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