ezdb 0.2.0

A declarative SQL library similary to Spring Data


To use this package, run the following command in your project's root directory:

Build Status

EzDb

EzDb is a database system similar to Spring Data JPA. It currently supports both SQLite and an in-memory database.

Usage

Here is a simple example that explains the usage of EzDb:

import ezdb;

// Define the entity representing a single record in a table.
struct SomeEntity
{
	@primaryKey
	int id;

	string someValue;
}

// A repository that functions as the interface to a repository.
interface SomeRepository : Repository!SomeEntity
{
}

// Create an instance for the repository.
auto db = makeRepository!SomeRepository;
scope(exit) db.close();

// Create an entity and save it.
SomeEntity newEntity;
newEntity.someValue = "hello, world!";
SomeEntity savedEntity = db.save(newEntity);

Unit-testing

A system requiring a database can easily be tested using the mockRepository function.

import ezdb;

unittest
{
	auto db = mockRepository!SomeRepository;
	SomeEntity mockEntity;
	mockEntity.someValue = "hello, test!";
	db.save(mockEntity);
	// Do the rest of the test here
}

Other functionality

All supported operations on a database can currently be found in the package ezdb.repository. Check out the documentation!

Authors:
  • Sebastiaan de Schaetzen
Dependencies:
d2sqlite3, optional
Versions:
0.2.0 2020-Feb-09
0.1.0 2020-Feb-04
~master 2020-Feb-09
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 89 downloads this month

  • 89 downloads total

Score:
1.1
Short URL:
ezdb.dub.pm