8000 GitHub - suisou/matador: Take your database by the horns
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

suisou/matador

 
 

Repository files navigation

matador

Take your database by the horns.

Version 0.6.1 GPLv3 C++11

Build Status

Branches Travis-CI AppVeyor-CI Coveralls
master Build Status Build status Coverage Status
develop Build Status Build status Coverage Status

matador is a ORM framework written in C++. It aims to encapsulate all database stuff (database backends, sql statements, serialization of objects) and provides the user an easy to use interface and a unique container for all objects. Given this container the user has a centralized point of storage for all objects at hand but with the ability to create views on concrete object types.

Features:

  • A unique fluent query interface
  • One to one/many relations
  • One storage container
  • Filter with simple expressions
  • Transactions
  • STL like interface and iterators

Supported databases:

  • PostgreSQL
  • SQLite
  • MySQL
  • MS SQL Server

Documentation can be found here.

Example

// use matador namespace
using namespace matador

// a simple person class
struct person
{
  identifier<long> id;   // primary key
  std::string name;
  unsigned int age = 0;
  has_many<varchar<255>> colors;
  
  person(long i, std::string n)
    : id(i), name(std::move(n))
  {}
  
  template < class SERIALIZER >
  void serialize(SERIALIZER &serializer) {
    serializer.serialize("id", id);
    serializer.serialize("name", name, 255);
    serializer.serialize(
7C30
"age", age);
    serializer.serialize("person_color", colors, "person_id",   "color");
    //                    table name     member   left column   right column
  }
};

// prepare the persistence layer
persistence p("sqlite://db.sqlite");
p.attach<person>("person");

// create tables
p.create();

// create a database session
session s(p);

// insert george
// returns an matador::object_ptr<person>
auto george = s.insert(new person(1, "george"));
// flush changes
s.flush();

// modify george
george.modify()->age = 35;
// add color
george.modify()->colors.push_back("brown");
s.flush();

// delete george
s.remove(george);
s.flush();

Requirements

The library has almost no dependencies. At least the database library you want to use. If you would like to build from the sources you need at least the cmake build system installed. If you plan to generate an install package on a windows system you need the nullsoft scriptable install system.

Sources

Get the sources from GitHub and enter the created directory:

$ git clone https://github.com/zussel/matador.git
$ cd matador

Building under Linux

Create a build directory change to it and call cmake:

$ mkdir build
$ cd build
$ cmake ..

Then you can build matador from sources:

$ make

Building under Windows (for Visual Studio)

Create a build directory change to it and call cmake:

$ mkdir build
$ cd build
$ cmake -G "Visual Studio *" ..

Where * is one of the "Visual Studio" strings up from "14". See cmake documentation here. After generation you find a matador.sln solution file in the current directory.

Contact

If you have questions or issues concerning matador you can place an issue in my matador github repository

About

Take your database by the horns

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 95.9%
  • CMake 3.9%
  • Other 0.2%
0