Simple cross-platform library based in the ActiveRecord from Ruby, an wrapper around SQL.
git clone https://github.com/Moonslate/database.git
mkdir build
cd build
cmake ..
make
User user;
user.name = "Dummy";
user.password = "Some Password";
user.age = 21;
user.save();
INSERT INTO users(name,password,age) VALUES ('Dummy','Some Password',21) RETURNING id;
User user = User::create({
{ "name", "Dummy" },
{ "password", "Some Password" }
{ "age", 21 }
});
database new-model user --migrate
#include <core.hpp>
#include <database.hpp>
class User : public uva::database::basic_active_record
{
uva_database_declare(User);
};
#include <user.hpp>
uva_database_define(User);
#include <core.hpp>
#include <database.hpp>
#include <user.hpp>
class AddUsersMigration : public uva::database::basic_migration
{
uva_declare_migration(AddUsersMigration);
protected:
virtual void change() override
{
add_table("users",
{
{ "id", "INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL" },
{ "updated_at", "INTEGER NOT NULL DEFAULT (STRFTIME('%s'))" },
{ "created_at", "INTEGER NOT NULL DEFAULT (STRFTIME('%s'))" },
{ "removed", "INTEGER NOT NULL DEFAULT 0" },
});
}
};
uva_define_migration(AddUsersMigration);
Columns are defined inside the map in second parameter of add_table
. Those columns are accessed by User::operator[](std::string)
, they'll only be available with the User::operator.
when exposing the column inside the class:
uva_database_expose_column(password);
- SQLite3
- Before save, update π
- Create database tool π
- Move multiple_value_holder to uva::core (and rename to var) π
- Create database_exception
- Strongly typed var π
- Complete Todo List of uva::string
- Complete Todo List of uva::string
- Complete Todo List of uva::cspec
- Have 100% of tests coverage
- π - Copy constructor of base class not works
Just make a PR! :)